#include<bits/stdc++.h>
using namespace std;
int main()
{
	int i=100;
 	while(199>=i){
 		if(i%3==2&&i%5==3&&i%7==5){
 			
 			cout<<i;
 			i+=1;
 			break;
		 }
 		
 		
 	i+=1;	
 		
	 }
	
	
	
	





	return 0;
}

/**************************************************************
	Problem: 1017
	User: zy002
	Language: C++
	Result: Accepted
	Time:3 ms
	Memory:2072 kb
****************************************************************/