#include <errno.h>
#include <limits.h>
#include <stdlib.h>
#include <stdio.h>

int main (int argc, char** argv) {
	char* resolved_path = NULL;

	if (argc == 2) {
		resolved_path = realpath(argv[1], NULL);
	} else {
		char* path;
		if (scanf("%as", &path) == 1) {
			resolved_path = realpath(path, NULL);
			free(path);
		} else {
			fprintf (stderr, "%s: No input.\n", argv[0]);
			return ENOENT;
		}
	}		
	
	if (resolved_path) {
		printf("%s\n", resolved_path);
		free(resolved_path);
		return 0;
	} else {
		perror (argv[0]);
		return errno;
	}
}
