#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define REP(i,a,b) for(int i=a;i<(int)b;i++) #define rep(i,n) REP(i,0,n) #define all(c) (c).begin(), (c).end() #define zero(a) memset(a, 0, sizeof a) #define minus(a) memset(a, -1, sizeof a) #define minimize(a, x) a = std::min(a, x) #define maximize(a, x) a = std::max(a, x) typedef long long ll; int const inf = 1<<29; namespace math { namespace prime { constexpr int Max = 364364; int prime[Max]; bool is_prime[Max]; int sieve(int n) { int prime_count = 0; rep(i, n+1) is_prime[i] = 1; is_prime[0] = is_prime[1] = 0; REP(i, 2, n+1) { if(!is_prime[i]) { continue; } prime[prime_count++] = i; for(long long j=(long long)i*i; j<=n; j+=i) { is_prime[j] = 0; } } return prime_count; } } } int main() { using namespace math::prime; sieve(114514); int n; cin >> n; if(is_prime[n-100]) { if(is_prime[n-99]) { cout << n-98 << endl; } else { cout << n-99 << endl; } } else { cout << n-100 << endl; } return 0; }