#include<iostream>
#include<cstring>
#include<queue>
#include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std;
#define maxn 1010
long long f(int n)
{
if(n==1)
return 0;
if(n==2)
return 1;
else return (n-1)*(f(n-1)+f(n-2));
}
int main()
{
int n;
while(~scanf("%d",&n))
{
cout << f(n) << endl;
}
return 0;
}