#include <iostream>
using namespace std;
#include<string>
#include<algorithm>
const int l = 100;
int a_arr[l], b_arr[l];
int c_arr[l], d_arr[l];
int n;
void cin_in_arr(string s, int a[]) {
int j = 0;
for (int i = s.size() - 1;i >= 0;i--)a[j++] = s[i]-48;
}
void print_arr(int a[], int len) {
for (int i = 0;i < len;i++)cout << a[i] << ' ';
}
string mymultiply(string a, string b) {
if (a == "0" || b == "0")return "0";
int arr[l] = { 0 };
cin_in_arr(a, a_arr);
cin_in_arr(b, b_arr);
for (int i = 0;i < a.size();i++)
for (int j = 0;j < b.size();j++)
arr[i + j] += a_arr[i] * b_arr[j];
for (int i = 0;i < a.size() + b.size();i++) {
arr[i + 1] += arr[i] / 10;
arr[i] = arr[i] % 10;
}
string res = "";
bool flag = false;
for (int i = a.size() + b.size();i >= 0;i--) {
if (arr[i] != 0||flag) {
flag =true;
res += to_string(arr[i]);
}
}
return res;
}
string myplus(string a, string b) {
if (a == "0" && b == "0")return "0";
int res[l] = { 0 };
cin_in_arr(a, c_arr);
cin_in_arr(b, d_arr);
int j = 0;
for (int i = 0;i < max(a.size(), b.size());i++) {
res[j++] = c_arr[i] + d_arr[i];
}
for (int i = 0;i < a.size() + b.size()+5;i++) {
res[i + 1] += res[i] / 10;
res[i] = res[i] % 10;
}
string c_res = "";
bool flag = false;
for (int i = max(a.size(), b.size());i >= 0;i--) {
if (res[i] != 0 || flag) {
c_res += to_string(res[i]);
flag = true;
}
}
return c_res;
}
int main()
{
cin >> n;
string res = "0";
string jie = "1";
for (int i = 1;i <= n;i++) {
jie = mymultiply(to_string(i), jie);
res = myplus(jie, res);
memset(a_arr, 0, sizeof(a_arr));
memset(b_arr, 0, sizeof(b_arr));
memset(c_arr, 0, sizeof(c_arr));
memset(d_arr, 0, sizeof(d_arr));
}
cout << res;
return 0;
}