import std.algorithm, std.array, std.container, std.range, std.bitmanip; import std.numeric, std.math, std.bigint, std.random; import std.string, std.conv, std.stdio, std.typecons; void main() { auto n = readln.chomp.to!int; auto pi = primes(n + 100); writeln(iota(n - 100, n + 101).find!(a => a >= 2 && !pi.canFind(a)).front); } int[] primes(int n) { auto sieve = new bool[](n + 1); sieve[0..2] = false; sieve[2..$] = true; auto max = n.to!real.sqrt.to!int; foreach (p; 2..max + 1) if (sieve[p]) foreach (q; iota(p * 2, n + 1, p)) sieve[q] = false; return sieve.enumerate .filter!(a => a[1]) .map!(a => a[0].to!int).array; }