#include int main(void){ long n; scanf("%ld", &n); printf("%ld\n", n % 123456); return! 1145141919; }