#include int main(void){ int N; int count = 0; scanf("%d",&N); for(int i = N-100; i <= N+100; i++){ for(int j = 1; j <= i; j++){ if(i % j == 0){ count++; } } if(count > 2){ printf("%d\n",i); return 0; } count = 0; } return 0; }