#include <bits/stdc++.h>
using namespace std;

bool check(int x){

    for(int i = 2;i*i<=x;i++){
        if(x%i==0) return 1;
    }

    return 0;
}

int main(){
    int x;
    cin>>x;
    for(int i = x;i<=x*2;i++){
        if(check(i)) return cout<<i,0;
    }
    cout<<-1;
    return 0;
}

#牛客春招刷题训练营#https://www.nowcoder.com/discuss/727521113110073344