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





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