#include <iostream>
#include <vector>
#include <iomanip>
using namespace std;
vector<int> multiply (const vector<int> &s, int b, int base) {
vector<int> c;
int carry = 0;
for (int i = 0; i < s.size(); i++) {
long long res = (long long)s[i] * b + carry;
carry = res / 1000;
c.push_back(res % base);
}
if (carry > 0) {
c.push_back(carry);
}
return c;
}
int main() {
int n;
int base = 1000;
cin >> n;
vector<int> res;
res.push_back(1);
for (int i = 1; i < n; i++) {
res = multiply(res, i + 1, base);
}
cout << res[res.size() - 1];
for (int i = res.size() - 2; i >= 1; i--) {
cout << setw(3) << setfill('0') << res[i];
}
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8dmVjdG9yPgojaW5jbHVkZSA8aW9tYW5pcD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKdmVjdG9yPGludD4gbXVsdGlwbHkgKGNvbnN0IHZlY3RvcjxpbnQ+ICZzLCBpbnQgYiwgaW50IGJhc2UpIHsKICB2ZWN0b3I8aW50PiBjOwogIGludCBjYXJyeSA9IDA7CiAgZm9yIChpbnQgaSA9IDA7IGkgPCBzLnNpemUoKTsgaSsrKSB7CiAgICBsb25nIGxvbmcgcmVzID0gKGxvbmcgbG9uZylzW2ldICogYiArIGNhcnJ5OwogICAgY2FycnkgPSByZXMgLyAxMDAwOwogICAgYy5wdXNoX2JhY2socmVzICUgYmFzZSk7ICAgIAogIH0KICBpZiAoY2FycnkgPiAwKSB7CiAgCWMucHVzaF9iYWNrKGNhcnJ5KTsKICB9CiAgcmV0dXJuIGM7Cn0KaW50IG1haW4oKSB7CiAgaW50IG47CiAgaW50IGJhc2UgPSAxMDAwOwogIGNpbiA+PiBuOwogIHZlY3RvcjxpbnQ+IHJlczsKICByZXMucHVzaF9iYWNrKDEpOwogIGZvciAoaW50IGkgPSAxOyBpIDwgbjsgaSsrKSB7CiAgICByZXMgPSBtdWx0aXBseShyZXMsIGkgKyAxLCBiYXNlKTsKICB9CiAgY291dCA8PCByZXNbcmVzLnNpemUoKSAtIDFdOwogIGZvciAoaW50IGkgPSByZXMuc2l6ZSgpIC0gMjsgaSA+PSAxOyBpLS0pIHsKICAgIGNvdXQgPDwgc2V0dygzKSA8PCBzZXRmaWxsKCcwJykgPDwgcmVzW2ldOwogIH0KfQo=