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