import std.stdio, std.conv, std.string, std.range, std.math, std.algorithm; void main() { auto N = readln.strip.to!int; foreach (x; max(2, N - 100).iota(N + 101)) { foreach (y; 2.iota(x)) { if (x % y == 0) { x.writeln; return; } } } }