import java.util.Scanner; class Main{ public static void main(String args[]){ Scanner sc = new Scanner(System.in); int N = Integer.parseInt(sc.next()); for(int i = N - 100; i <= N + 100; i++){ if(1 <= i && i <= 3){ continue; } else if(i % 2 == 1 && ( i % 3 == 0 || i % 5 == 0) ){ continue; } else{ System.out.println(i); break; } } } }