#include<iostream> using namespace std; int main(){ int i=0; cin>>i; while(1){ i++; if(i%3==2&&i%5==3&&i%7==2){ cout<<i; break; } } return 0; }