#include <bits/stdc++.h>
using namespace std;
long long a[55], n, cnt, f;
void w() {
long long sum = 10;
for (int i = 0; i < log10(cnt) + 1; i++) {
a[i] = cnt / sum % (sum / 10);
sum = sum * 10;
}
f = log10(cnt) + 1;
}
void l(int wel) {
int sum = a[wel] / 10;
a[wel] = a[wel] % 10;
a[wel + 1] += sum;
f++;
if (a[wel + 1] >= 10) l(wel + 1);
}
int main() {
cin >> n;
if (n < 22) {
int sum = 1;
for (int i = 1; i <= n; i++) {
sum = sum * i;
cnt = cnt + sum;
}
cout << cnt;
return 0;
}
long long sum1 = 1;
for (int i = 1; i <= n; i++) {
if (i == 10) w();
if (i >= 10) {
long long sum = 10;
for (int j = 0; j < log10(i) + 1; j++) {
a[j] = a[j] * cnt / sum % (sum / 10);
sum = sum * 10;
if (a[j] >= 10) l(j);
}
}
else {
sum1 = sum1 * i;
cnt = cnt + sum1;
}
}
for (int i = 0; i <= f; i++) {
cout << a[f];
}
return 0;
}