content: package v104;
  
  import java.io.BufferedReader;
  import java.io.IOException;
  import java.io.InputStream;
  import java.io.InputStreamReader;
  import java.io.PrintWriter;
  import java.math.BigInteger;
  import java.util.StringTokenizer;
  
  public class SweetChildMakesTrouble_UVa10497 {
  
  	static BigInteger[] memo = new BigInteger[801];
  	
  	static BigInteger D(int n)
  	{
  		if(n == 1)
  			return BigInteger.ZERO;
  		if(n == 0)
  			return BigInteger.ONE;
  		if(memo[n] != null)
  			return memo[n];
  		return memo[n] = BigInteger.valueOf(n-1).multiply(D(n - 1).add(D(n - 2)));
  	}
  	
  	public static void main(String[] args) throws IOException 
  	{
  		Scanner sc = new Scanner(System.in);
  		PrintWriter out = new PrintWriter(System.out);
  	
  		while(true)
  		{
  			int n = sc.nextInt();
  			if(n == -1)
  				break;
  			out.println(D(n));
  		}
  		out.flush();
  		out.close();
  	}
  
  	static class Scanner 
  	{
  		StringTokenizer st;
  		BufferedReader br;
  
  		public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}
  
  		public String next() throws IOException 
  		{
  			while (st == null || !st.hasMoreTokens()) 
  				st = new StringTokenizer(br.readLine());
  			return st.nextToken();
  		}
  
  		public int nextInt() throws IOException {return Integer.parseInt(next());}
  
  		public long nextLong() throws IOException {return Long.parseLong(next());}
  
  		public String nextLine() throws IOException {return br.readLine();}
  
  		public double nextDouble() throws IOException { return Double.parseDouble(next()); }
  
  		public boolean ready() throws IOException {return br.ready();}
  
  	}
  }