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