#include using namespace std; using LL = long long; using ULL = unsigned long long; #define rep(i,n) for(int i=0; i<(n); i++) int main() { ULL N; cin >> N; cout << (N % 123456) << endl; return 0; }