// Safe Primes.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include "iostream.h"
int CheckPrime(int number);
int main(int argc, char* argv[])
{

	int number,k=2,done=0,count=1,prime[600],Whichone,test,result,result2;
	int Answer;
	double safeprime[500];
	//generate primes
	safeprime[0]=5;
	for (number=2;number<35000;number++)
	{
       result=CheckPrime(number);
	   if (result==0)
	   {    test=2*number+1;
		    result2=CheckPrime(test);
		   if (result2==0)
		   {
			   
		    safeprime[count]=test;
			count++;
		   }
	   }
	 }
	


	cin>>Whichone;
	cout<<safeprime[Whichone-1];
	
	return 0;
}
int CheckPrime(int number)
{int k,done;
	   k=2;
	   done=0;
       do
	   {
		   if ((number%k)==0)
		   {
		    done=1;
		   }
		   else
			   k++;
	   }while(k<number/2 && done==0);
return(done);
}