class C {public static void main(String[]s){int n=new java.util.Scanner(System.in).nextInt(),p=2,j,k=1,t=0,a=1,b=0,c;z:for(;t<n;p++){for(j=1;++j<p;)if(p%j<1)continue z;t++;}j=(int)Math.round(Math.sqrt(n)%1*10);for(t=0;t++<j;k*=t);for(c=j=n*n;(j/=10)>9;);for(t=0;++t<j;a+=b,b=a-b);System.out.print(p-1+c+(c+n)/2+c*n+k+a);}}
Ungolfed:
class C {
public static void main(String[] args) {
int n = new java.util.Scanner(System.in).nextInt(), p = 2,
j,
k = 1,
t,
a = 1,
b = 0,
c;
// prime
z:
for (t = 0; t < n; p++) {
for (j = 1; ++j < p; ) {
if (p % j < 1) {
continue z;
}
}
t++;
}
// factorial
j = (int) Math.round(Math.sqrt(n) % 1 * 10);
for (t = 0; t++ < j; k *= t);
// fibonacci
for (c = j = n * n; (j /= 10) > 9;);
for (t = 0; ++t < j; ) {
a += b, b = a - b);
}
System.out.print(p - 1 + c + (c + n) / 2 + c * n + k + a);
}
}