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