import std; void main() { int N; readf("%d\n", N); int limit = 10 ^^ 5; int size = limit * 2; int ssqrt = size.to!real.sqrt.floor.to!int; auto sieve = iota(0, size).map!(i => i == 2 || (i > 2 && i % 2 == 1)).array; foreach (i; iota(3, ssqrt, 2)) { if (!sieve[i]) { continue; } foreach (j; iota(i*i, size, i)) { sieve[j] = false; } } auto nice = iota(0, size).filter!(i => i == 1 || (i > limit && sieve[i])).array; nice[N-1].writeln; }