#define _USE_MATH_DEFINES #include #include #include #include #include #include #include #include #include #include #include #include #define mod (ll)(1e9+7); using namespace std; typedef long long ll; typedef pair Pr; ll N; string cur,pre; int main() { cin >> N; if (N >= 50) { cout << "000000000000" << endl; return 0; } ll ans = 1; bool flag = true; string s; for (int i = 1; i <= N; i++) { ans *= i; cur = to_string(ans); if (cur.size() >= 12 && pre.size() >= 12) { s = ""; for (int j= 1; j <= 12; j++) { s += cur[cur.size() - (12 - j + 1)]; if (cur[cur.size() - j] != pre[pre.size() - j]) { flag = false; } } ans = stoll(s); if (flag) { break; } } pre = cur; if (cur.size() < 12) s = cur; } cout << s << endl; return 0; }