#include <iostream>
using namespace std;
double C(int m, int n)
{
double i, cn = 1, cm = 1, cc = 1;
for (i = 1; i <= n; i++)
cn *= i;
for (i = 1; i <= m; i++)
cm *= i;
for (i = 1; i <= (n - m); i++)
cc *= i;
return cn / cm / cc;
}
double f(int i)
{
if (i == 0) return 1;
if (i == 1) return 0;
if (i == 2) return 1;
if (i == 3) return 2;
return (i - 1)*(f(i - 1) + f(i - 2));
}
int main()
{
int n;
while (cin >> n)
{
if (n == 0) break;
long long sum=0;
for (int i = 0; i <= n / 2; i++)
{
sum += C(i,n)* f(i);
}
cout << sum << endl;
}
return 0;
}