PolandBall is a young, clever Ball. He is interested in prime numbers. He has stated a following hypothesis: "There exists such a positive integer n that for each positive integer m number n·m + 1 is a prime number".

Unfortunately, PolandBall is not experienced yet and doesn't know that his hypothesis is incorrect. Could you prove it wrong? Write a program that finds a counterexample for any n.


-----Input-----

The only number in the input is n (1 ≤ n ≤ 1000) — number from the PolandBall's hypothesis. 


-----Output-----

Output such m that n·m + 1 is not a prime number. Your answer will be considered correct if you output any suitable m such that 1 ≤ m ≤ 10^3. It is guaranteed the the answer exists.


-----Examples-----
Input
3

Output
1
Input
4

Output
2


-----Note-----

A prime number (or a prime) is a natural number greater than 1 that has no positive divisors other than 1 and itself.

For the first sample testcase, 3·1 + 1 = 4. We can output 1.

In the second sample testcase, 4·1 + 1 = 5. We cannot output 1 because 5 is prime. However, m = 2 is okay since 4·2 + 1 = 9, which is not a prime number.

Difficulty: EASY
Tags: Number theory

Graph algorithms

Mathematics

Complete search
Skill types: Complete search

Starter code:

Solutions:
def is_prime(adad):
	if adad == 2:
		return True
	else:
		saquare = int(adad ** 0.5) + 1
		counter = 2
		while counter < saquare:
			if adad % counter != 0:
				counter += 1
			else:
				return False
		return True
vurudi_asli = int(input())
prime_check = True
zarib = 1
while prime_check:
	vurudi = vurudi_asli * zarib + 1
	if is_prime(vurudi) == True:
		zarib += 1
	else:
		print(zarib)
		prime_check = False


import math
n = int(input())
if n % 2 == 1 and n != 1:
	print(1)
else:
	for i in range(1000):
		for j in range(2, int(math.sqrt(n * i + 1)) + 1):
			if (n * i + 1) % j == 0:
				print(i)
				exit()


n = int(input())
if n == 1:
	print(3)
elif n == 2:
	print(4)
elif n % 2 == 1:
	print(1)
else:
	print(n - 2)


isp = [True] * (10 ** 6 + 8)
isp[0] = isp[1] = False
i = 2
N = 10 ** 6 + 7
while i * i <= N:
	if isp[i]:
		for j in range(i * i, N + 1, i):
			isp[j] = False
	i += 1
n = int(input())
for m in range(1, 1001):
	if not isp[n * m + 1]:
		print(m)
		break


a = int(input())
for i in range(1000000):
	k = 0
	x = a * (i + 1) + 1
	for j in range(2, x):
		if x % j == 0:
			k = 1
			break
	if k == 1:
		print(i + 1)
		break


def is_prime(n):
	result = True
	for i in range(2, n):
		if n % i == 0:
			result = False
			break
	return result

def hypothesis(n, m=1):
	if not is_prime(n * m + 1):
		return m
	else:
		return hypothesis(n, m + 1)
print(hypothesis(int(input())))


import math
n = int(input())

def isPrime(x):
	if x in [2, 3, 5, 7]:
		return True
	if x == 1:
		return False
	for i in range(2, int(math.sqrt(x)) + 1):
		if x % i == 0:
			return False
	return True
m = 1
while True:
	if isPrime(n * m + 1) == False:
		print(m)
		exit()
	m += 1


import math

def is_prime(num):
	if num % 2 == 0 and num != 2:
		return False
	for i in range(2, int(math.sqrt(num)) + 1):
		if num % i == 0:
			return False
	return True
n = int(input())
for i in range(1, 1000 + 1):
	if not is_prime(i * n + 1):
		print(i)
		break


n = int(input())
if n <= 2:
	print('{}'.format(n + 2))
else:
	print('{}'.format(n - 2))


n = int(input())

def ispr(m):
	i = 2
	while i * i <= m:
		if m % i == 0:
			return False
		i += 1
	return True
for i in range(1, 1001):
	if not ispr(n * i + 1):
		print(i)
		exit(0)


def funcao(n):
	m = 1
	while m <= 1000:
		numero = n * m + 1
		for e in range(2, numero):
			if numero % e == 0:
				return m
		m += 1
print(funcao(int(input())))


3

def is_prime(x):
	if x == 1:
		return False
	i = 2
	while i * i <= x:
		if x % i == 0:
			return False
		i += 1
	return True
n = int(input())
m = 1
while is_prime(n * m + 1):
	m += 1
print(m)


n = int(input())

def prime(n):
	for i in range(2, n):
		if n % i == 0:
			return False
	return True
for i in range(1, 10 ** 3):
	x = prime(n * i + 1)
	if x == False:
		print(i)
		break


x = int(input())
if x == 1:
	print(3)
elif x == 2:
	print(4)
else:
	print(x - 2)


import math

def is_prime(n):
	for i in range(2, int(math.sqrt(n) + 1)):
		if n % i == 0:
			return False
	return True
n = int(input())
for m in range(1, 1001):
	if not is_prime(n * m + 1):
		print(m)
		break


sieve = [1] * 1000000
sieve[0] = 0
sieve[1] = 0
for i in range(1000000):
	if sieve[i] == 1:
		j = i * i
		while j < 1000000:
			sieve[j] = 0
			j += i
n = int(input())
m = 1
while True:
	if sieve[n * m + 1] == 0:
		print(m)
		break
	else:
		m += 1


limit = 20000
prime = [True for i in range(limit + 1)]
p = 2
while p * p <= limit:
	if prime[p]:
		for i in range(p * 2, limit + 1, p):
			prime[i] = False
	p += 1
n = int(input())
for m in range(1001):
	if not prime[n * m + 1]:
		print(m)
		break


n = int(input())
m = 1
if n <= 2:
	if n == 1:
		m = 3
	elif n == 2:
		m = 4
else:
	for i in range(2, n):
		if (n * m + 1) % i == 0:
			break
		else:
			m += 1
print(m)


def pr(n):
	i = 2
	while i ** 2 <= n:
		if n % i == 0:
			return False
		i += 1
	return True
n = int(input())
for m in range(1, 1001):
	if not pr(n * m + 1):
		print(m)
		break


n = int(input())
a = [3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997]
if n % 2 is 1:
	print(3)
elif n is 2:
	print(4)
else:
	for i in a:
		if n % i != 0:
			break
	x = 1
	while 1:
		if (n * x + 1) % i is 0:
			print(x)
			break
		x = x + 1


m = int(input())
if m > 2:
	print(m - 2)
else:
	print(17)


num = int(input())
i = 1
s = ''
while True:
	for j in range(2, num * i + 1):
		if (num * i + 1) % j == 0:
			s = 'Yes'
			break
	if s == 'Yes':
		print(i)
		break
	i += 1


from math import sqrt

def GCD(a, b):
	if a == 0:
		return b
	elif b == 0:
		return a
	else:
		return GCD(b, a % b)

def is_prime(n: int) -> bool:
	for i in range(2, int(sqrt(n)) + 3):
		if i < n and n % i == 0:
			return False
	return True
n = int(input())
if n % 2 == 1:
	print(3)
else:
	for i in range(1, 1000):
		if not is_prime(n * i + 1):
			print(i)
			break


n = int(input())
if n % 2:
	print(3)
else:
	i = f = 1
	while i:
		for j in range(2, (n * i + 1) // 2 + 1):
			if (n * i + 1) % j == 0:
				f = 0
				break
		if f == 0:
			break
		i += 1
	print(i)


def f(x):
	fl = 1
	for n in range(3, int(x ** 0.5) + 2, 2):
		if x % n == 0 and x != 3:
			fl = 0
			break
	return fl
x = int(input())
if x % 2 == 1:
	if x != 1:
		print(1)
	else:
		print(3)
elif f(x + 1) == 0:
	print(1)
elif f(x + 1) == 1:
	n = 1
	while 1:
		if f(x * n + 1) == 0:
			print(n)
			break
		else:
			n += 1


def prime(m):
	f = 0
	for i in range(2, m):
		if m % i == 0:
			break
	else:
		f = 1
	return f
c = 0
n = int(input())
for i in range(1, 1000):
	if prime(n * i + 1) == 0:
		c = i
		break
print(c)


def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True
n = int(input())
for i in range(1, 1000):
	a = n * i + 1
	if not isPrime(a):
		print(i)
		break


n = int(input())
for m in range(1, 1000 + 1):
	aux = n * m + 1
	achou = False
	for e in range(1, 12):
		if aux % e == 0 and aux != e and (e != 1):
			achou = True
			break
	if achou:
		print(m)
		break


import sys, math, string
input = sys.stdin.readline
L = lambda : list(map(int, input().split()))
Ls = lambda : list(input().split())
M = lambda : map(int, input().split())
I = lambda : int(input())
n = I()
print(min(n + 2, 999))


def check(p):
	for x in range(2, p - 1):
		if p % x == 0:
			return False
	return True
n = int(input())
ans = -1
for x in range(1, 1000):
	if not check(x * n + 1):
		ans = x
		break
print(ans)


n = int(input())
m = 1
while True:
	aux = n * m + 1
	i = 2
	while True:
		if aux % i == 0:
			break
		i += 1
	if i == aux:
		m += 1
	else:
		print(m)
		break


from math import *
n = int(input())
flag = 0
if n == 2:
	print(4)
elif n == 1:
	print(3)
elif n % 2 == 1:
	print(1)
else:
	for i in range(1, 100):
		for j in range(2, int(sqrt(n * i + 1) + 1)):
			if (i * n + 1) % j == 0:
				flag = 1
				break
		if flag:
			print(i)
			break


import sys
from collections import defaultdict
mod = 1000000007

def get_array():
	return list(map(int, sys.stdin.readline().split()))

def get_ints():
	return map(int, sys.stdin.readline().split())

def input():
	return sys.stdin.readline()

def print_array(a):
	print(' '.join(map(str, a)))

def main():
	n = int(input())
	if n == 1:
		print('3')
	elif n == 2:
		print('4')
	else:
		print(n - 2)
main()


def p(x):
	for i in range(2, int(x ** 0.5) + 1):
		if x % i == 0:
			return 1
	else:
		return 0
n = int(input())
for m in range(1, 10000):
	if p(n * m + 1) == 1:
		print(m)
		break


n = int(input())
if n == 999:
	print(1)
elif n == 1000:
	print(2)
else:
	print(n + 2)


from math import sqrt
n = int(input())
a = 0
m = 0
while True:
	m += 1
	a = n * m + 1
	for i in range(2, int(sqrt(a) + 1)):
		if a % i == 0:
			print(m)
			return


x = int(input())
if x > 500:
	print(x - 2)
else:
	print(x + 2)


n = int(input())
if n > 2:
	print(n - 2)
else:
	print(7)


import math

def checkprime(num):
	d = math.sqrt(num)
	for i in range(2, int(d) + 1):
		if num % i == 0:
			return 0
n = int(input())
flag = False
for m in range(1, 1001):
	x = checkprime(n * m + 1)
	if x == 0:
		print(m)
		flag = True
		break


import math
N = int(input())
if N % 2 != 0:
	print(3)
	exit()

def check(n):
	if n == 1:
		return False
	if n == 2:
		return True
	for i in range(2, int(math.sqrt(n)) + 1):
		if n % i == 0:
			return False
	return True
for m in range(1, 1000 + 10):
	tmp = N * m + 1
	if not check(tmp):
		print(m)
		exit()


from sys import stdin, stdout
from collections import Counter
st = lambda : list(stdin.readline().strip())
li = lambda : list(map(int, stdin.readline().split()))
mp = lambda : map(int, stdin.readline().split())
inp = lambda : int(stdin.readline())
pr = lambda n: stdout.write(str(n) + '\n')
n = inp()
if n == 1:
	pr(3)
elif n == 2:
	pr(4)
else:
	pr(n - 2)


n = int(input())
if n > 3:
	print(n - 2)
else:
	print(n + 2)


import sys
from math import ceil, floor, log2, sqrt

def readall():
	return [int(x) for x in sys.stdin.read().split()]

def u():
	return [int(i) for i in sys.stdin.readline().split()]
n = u()[0]

def pc(x):
	if x == 2:
		return True
	if x % 2 == 0:
		return False
	i = 3
	while i ** 2 <= x:
		if x % i == 0:
			return False
		i += 2
	return True
for i in range(1, 1001):
	if not pc(n * i + 1):
		print(i)
		exit()


def checkprime(n):
	if n == 1:
		return False
	elif n == 2 or n == 3:
		return True
	else:
		for i in range(2, int(n ** 0.5) + 1):
			if n % i == 0:
				return False
		return True
n = int(input())
if n == 1:
	print('3')
elif n % 2 != 0:
	print('1')
else:
	for i in range(1, 1001):
		if not checkprime(1 + i * n):
			print(i)
			break


import sys
input = sys.stdin.readline
n = int(input())
if n % 2 == 1:
	print(3)
else:
	for i in range(1000):
		a = n * i + 1
		for j in range(3, 100, 2):
			if a > j and a % j == 0:
				exit(print(i))


n = int(input())
if n % 2 != 0:
	print(11)
elif n % 5 == 1:
	print(14)
elif n % 5 == 2:
	print(12)
elif n % 5 == 3:
	print(8)
elif n % 5 == 4:
	print(11)
else:
	z = 1
	while True:
		if int((n * z + 1) ** 0.5) ** 2 == n * z + 1:
			print(z)
			break
		z += 1


def prime(x):
	mind = True
	for y in range(2, x):
		if x % y == 0:
			mind = False
			break
	return mind
n = int(input())
m = 1
while 1 > 0:
	ans = n * m + 1
	m = m + 1
	if prime(ans):
		continue
	else:
		print(m - 1)
		break


q = int(input())
t = True
for i in range(1, 10 ** 3 + 1):
	w = q * i + 1
	for r in range(2, w // 2 + 2):
		if w % r == 0 and w != r:
			print(i)
			t = False
			break
	if t == False:
		break


def checa_nao_primo(numero):
	for i in range(2, numero // 2):
		if numero % i == 0:
			return True
	return False
n = int(input())
if n == 0:
	print(0)
elif n % 2 == 1 and n != 1:
	print(1)
else:
	m = 1
	while True:
		if checa_nao_primo(n * m + 1):
			break
		else:
			m += 1
	print(m)


def prime(n):
	for i in range(2, n):
		if n % i == 0:
			return False
	else:
		return True
n = int(input())
m = 1
for i in range(1000):
	if prime(n * m + 1) == False:
		print(m)
		break
	else:
		m += 1


n = int(input())
if n <= 2:
	print(7)
elif n % 2 == 1:
	print(1)
else:
	print(n - 2)


def isPrime(n):
	if n == 2 or n == 3:
		return True
	if n % 2 == 0 or n < 2:
		return False
	for i in range(3, int(n ** 0.5) + 1, 2):
		if n % i == 0:
			return False
	return True
n = int(input())
flag = 0
m = 1
while m <= 1000 and flag == 0:
	if isPrime(n * m + 1) == False:
		flag = 1
		print(m)
	m += 1


import math

def check(n):
	q = int(math.sqrt(n))
	for i in range(2, q + 1):
		if not n % i:
			return False
	return True
n = int(input())
for i in range(1, 1000):
	if not check(n * i + 1):
		print(i)
		break


n = int(input())
if n == 1:
	print(3)
elif n % 2 == 1:
	print(1)
elif n == 1000:
	print(1)
else:
	print(n + 2)


prime = [2, 3, 5, 7, 11, 13, 17, 19]

def GenPrime(maxV: int, start=21):
	for x in range(start, maxV, 2):
		isprime = True
		for v in prime:
			if x % v == 0:
				isprime = False
				break
		if isprime:
			prime.append(x)

def IsPrime(k: int) -> bool:
	for x in prime:
		if k == x:
			return True
		if k % x == 0:
			return False
	return True
n = int(input())
GenPrime(1000)
m = 1
while IsPrime(m * n + 1):
	m += 1
print(m)


from math import sqrt

def is_prime(num):
	n = int(sqrt(num)) + 1
	for m in range(2, n):
		if num % m == 0:
			return True
	return False
a = int(input())
for m in range(1, 1001):
	n = a * m + 1
	if is_prime(n):
		print(m)
		break


def primes(n):
	sieve = [True] * n
	for i in range(3, int(n ** 0.5) + 1, 2):
		if sieve[i]:
			sieve[i * i::2 * i] = [False] * int((n - i * i - 1) / (2 * i) + 1)
	return [2] + [i for i in range(3, n, 2) if sieve[i]]

def main():
	n = int(input())
	x = primes(1000069)
	for m in range(1, 1001):
		if not n * m + 1 in x:
			print(m)
			return
main()


n = int(input())
print(n + 2 if n < 908 else n - 2)


x = int(input())
m = 1
k = 0
while True:
	for i in range(2, x * m + 1):
		if (x * m + 1) % i == 0:
			k = 1
			break
	if k == 1:
		break
	else:
		m += 1
print(m)


def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i ** 2 <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i += 6
	return True
n = int(input())
i = 1
while True:
	if not isPrime(n * i + 1):
		break
	i += 1
print(i)


def prime(x):
	if x < 2:
		return False
	if x == 2:
		return True
	if x % 2 == 0:
		return False
	for d in range(3, x, 2):
		if d * d > x:
			break
		if x % d == 0:
			return False
	return True

def main():
	n = int(input())
	for m in range(1, 1001):
		if not prime(n * m + 1):
			ans = m
			break
	print(ans)
main()


n = input()
N = int(n, 10)
m = 1
while m > 0:
	x = int(m * N) + 1
	i = 2
	bool = False
	while i * i <= x:
		if x % i == 0:
			print(m)
			bool = True
			break
		i += 1
	if bool:
		break
	m += 1


import math
import sys

def dict_sort(ans):
	ans = sorted(ans.items(), reverse=True, key=lambda kv: kv[1])

def is_prime(n):
	if n == 1:
		return 0
	for i in range(2, int(math.sqrt(n)) + 1):
		if n % i == 0:
			return False
	return True

def swap(a, b):
	temp = a
	a = b
	b = temp
	return (a, b)

def seive_primes(n):
	flag = [0] * (n + 10)
	flag[1] = flag[0] = 1
	i = 2
	while i * i <= n + 1:
		if flag[i] == 0:
			j = i * i
			while j <= n + 1:
				flag[j] = 1
				j += i
		i += 1
	return flag

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)

def lcm(a, b):
	return a * b // gcd(a, b)

def alphabates():
	return 'abcdefghijklmnopqrstuvwxyz'

def binary_search(ls, n, flag):
	low = 0
	hi = n - 1
	while low <= hi:
		mid = (low + hi) // 2
		if ls[mid] == flag:
			return mid
		elif ls[mid] > flag:
			hi = mid - 1
		else:
			low = mid + 1
	return -1

def qdrt(x, a, b, c):
	return a * x * x + b * x + c

def inp():
	ls = list(map(int, input().split()))
	return ls

def mult_inp():
	return map(int, input().split())
for _ in range(1):
	n = int(input())
	if n == 1:
		print(3)
	elif n == 2:
		print(4)
	else:
		print(n - 2)


import math

def is_prime(n):
	if n % 2 == 0 and n > 2:
		return False
	return all((n % i for i in range(3, int(math.sqrt(n)) + 1, 2)))
n = int(input())
for i in range(1, 1001):
	if not is_prime(n * i + 1):
		print(i)
		break


def isPrime(n):
	if n < 4:
		return True
	for i in range(2, round(n ** (1 / 2)) + 2):
		if n % i == 0:
			return False
	return True
n = int(input())
m = 1
while True:
	if not isPrime(m * n + 1):
		print(m)
		break
	m += 1


N = int(input())

def isPrime(x):
	if x <= 3:
		return True
	for i in range(2, int(x ** 0.5) + 2):
		if x % i == 0:
			return False
	return True
for i in range(1, 1000):
	a = i * N + 1
	if not isPrime(a):
		print(i)
		exit()


def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i += 6
	return True
n = int(input())
for i in range(1, 10 ** 3 + 1):
	x = n * i + 1
	if isPrime(x) == False:
		print(i)
		break


from math import sqrt
N = int(input())

def isPrime(n):
	for i in range(2, int(sqrt(n) + 1)):
		if n % i == 0:
			return False
	else:
		return True
for m in range(1, 1000):
	if not isPrime(N * m + 1):
		print(m)
		break


n = int(input())
if n <= 1000 - 5:
	print(n + 2)
else:
	print(n - 2)


def prime(n):
	for i in range(2, n // 2 + 1):
		if n % i == 0:
			return 1
	return 0
n = int(input())
k = 0
m = 1
while k != 1:
	k = prime(n * m + 1)
	d = m
	m += 1
print(d)


n = int(input())
if n > 500:
	print(n - 2)
else:
	print(n + 2)


n = int(input())
if n == 1000 or n == 999:
	print(1)
else:
	print(n + 2)


import math

def isprime(n):
	flag = 0
	for i in range(2, int(math.sqrt(n)) + 1):
		if n % i == 0:
			flag = 1
			break
	if flag == 1:
		return 0
	else:
		return 1
n = int(input())
if n == 1:
	print(3)
elif n % 2 != 0:
	print(1)
else:
	for h in range(1, 1001):
		if isprime(n * h + 1) == 0:
			print(h)
			break


from math import trunc, sqrt

def trueprime(a):
	for i in range(2, trunc(sqrt(a)) + 1):
		if a % i == 0:
			return False
	return True
n = int(input())
for m in range(1, 1002):
	if not trueprime(m * n + 1):
		print(m)
		break


import sys
import re
import math
import itertools
import collections
import bisect
mod = 1000000007
pi = 3.141592653589793
IS = float('inf')
xy = [(1, 0), (-1, 0), (0, 1), (0, -1)]
bs = [(-1, -1), (-1, 1), (1, 1), (1, -1)]

def niten(a, b):
	return abs(a - b) if a >= 0 and b >= 0 else a + abs(b) if a >= 0 else abs(a) + b if b >= 0 else abs(abs(a) - abs(b))

def fib(n):
	return [(seq.append(seq[i - 2] + seq[i - 1]), seq[i - 2])[1] for seq in [[0, 1]] for i in range(2, n)]

def gcd(a, b):
	return a if b == 0 else gcd(b, a % b)

def lcm(a, b):
	return a * b / gcd(a, b)

def eucl(x1, y1, x2, y2):
	return ((x1 - x2) ** 2 + (y1 - y2) ** 2) ** 0.5

def choco(xa, ya, xb, yb, xc, yc, xd, yd):
	return 1 if abs((yb - ya) * (yd - yc) + (xb - xa) * (xd - xc)) < 1e-10 else 0

def pscl(num, l=[1]):
	for i in range(num):
		l = map(lambda x, y: x + y, [0] + l, l + [0])
	return l

def prime_t(t):
	i = 2
	while i ** 2 <= t:
		if t % i == 0:
			return 0
		i += 1
	return 1
l = []
for i in range(2, 10000):
	if prime_t(i):
		l.append(i)
n = int(input())
for i in range(1, 1001):
	if n * i + 1 not in l:
		print(i)
		return


n = int(input())

def ARG(n):
	for i in range(2, n + 1):
		if (n + 1) % i == 0:
			return 1
	return 2
k = 1
p = n * k
while ARG(p) == 2:
	k = k + 1
	p = n * k
print(k)


n = int(input())
if n == 1:
	print(3)
elif n == 2:
	print(4)
elif n == 4:
	print(2)
elif n % 2 != 0:
	print(1)
elif n % 10 == 2:
	print(2)
elif n % 10 == 4:
	print(1)
elif n % 10 == 6:
	print(4)
elif n % 10 == 8:
	print(8)
elif n % 10 == 0:
	print(n - 2)


n = int(input())
new_n = n * 1000 + 1
pr = [1] * (new_n + 1)
pr[0] = pr[1] = 0
for i in range(2, new_n + 1):
	if pr[i] == 1:
		if i * i <= new_n:
			for j in range(i * i, new_n + 1, i):
				pr[j] = 0
for i in range(n + 1, new_n + 1):
	if pr[i] == 0 and (i - 1) % n == 0:
		print((i - 1) // n)
		break


a = int(input())
if a > 2:
	print(a - 2)
elif a == 1:
	print(3)
else:
	print(7)


n = int(input())
for i in range(1, 10 ** 3 + 1):
	var = n * i + 1
	for j in range(2, var):
		if var % j == 0:
			print(i)
			exit()


n = int(input())
m = 1
d = 2
while True:
	teste = n * m + 1
	if teste > d and teste % d == 0:
		print(m)
		break
	if teste > 2 and teste % 2 == 0:
		print(m)
		break
	if teste > 3 and teste % 3 == 0:
		print(m)
		break
	if teste > 5 and teste % 5 == 0:
		print(m)
		break
	d += 1
	m += 1


def is_prime(n):
	i = 2
	while i * i <= n:
		if n % i == 0 and i != n:
			return False
		i += 1
	return True

def solve(n):
	if n == 1:
		return 3
	m = 1
	while True:
		if not is_prime(n * m + 1):
			return m
		m += 1

def main():
	n = int(input())
	print(solve(n))
main()


import os
import sys
from math import *
from collections import *
from fractions import *
from bisect import *
from heapq import *
from io import BytesIO, IOBase

def vsInput():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def value():
	return tuple(map(int, input().split()))

def array():
	return [int(i) for i in input().split()]

def Int():
	return int(input())

def Str():
	return input()

def arrayS():
	return [i for i in input().split()]

def prime(n):
	pr = [True] * (n + 1)
	pr[1] = False
	p = 2
	while p * p <= n:
		if pr[p] == True:
			for j in range(p * p, n + 1, p):
				pr[j] = False
		p += 1
	return set([i for i in range(len(pr)) if pr[i]])
n = Int()
if n % 2:
	print(3)
else:
	pr = prime(100000)
	i = 0
	while True:
		i += 1
		if i * n + 1 not in pr:
			print(i)
			exit()


n = int(input())
print(min(n + 2, 999))


from math import sqrt

def min_divisor(x):
	i = 2
	while x % i != 0:
		if i >= sqrt(x):
			return x
		i += 1
	return i
n = int(input())
for k in range(1, 1001):
	if n * k + 1 != min_divisor(n * k + 1):
		print(k)
		break


num = int(input())
if num % 2:
	if num > 2:
		print(1)
	else:
		print(3)
elif num <= 2:
	print(4)
else:
	print(num - 2)


n = int(input())
if n == 1000:
	print(n - 2)
else:
	print(9 if n % 2 == 1 else n + 2)


def is_prime(number):
	result = True
	for x in range(2, number):
		if not number % x:
			result = False
			break
	return result

class CodeforcesTask755ASolution:

	def __init__(self):
		self.result = ''
		self.n = 0

	def read_input(self):
		self.n = int(input())

	def process_task(self):
		for m in range(1, 1000):
			if not is_prime(m * self.n + 1):
				self.result = str(m)
				break

	def get_result(self):
		return self.result
Solution = CodeforcesTask755ASolution()
Solution.read_input()
Solution.process_task()
print(Solution.get_result())


import sys
n = int(sys.stdin.readline().strip())
if n == 1:
	print(3)
elif n == 2:
	print(4)
elif n > 2 and n % 2 == 1:
	print(1)
elif n > 2 and n % 2 == 0:
	print(n - 2)


n = int(input())

def isprime(num):
	for i in range(2, num):
		if num % i == 0:
			return False
	return True
for i in range(1, 1000):
	val = n * i + 1
	if isprime(val):
		continue
	else:
		print(i)
		break


from math import sqrt

def simple(a):
	if a == 1 or a == 2 or a == 3:
		return True
	end = int(sqrt(a))
	for i in range(2, end + 1):
		if a % i == 0:
			return False
	return True

def myf(n):
	if n == 1:
		return 5
	elif n == 2:
		return 4
	elif n % 2 == 1:
		return 1
	else:
		cont = True
		a = 1
		while cont:
			test_number = n * a + 1
			if simple(test_number) == False:
				cont = False
			else:
				a += 1
		return a
n = int(input())
print(myf(n))


import math
a = int(input())

def prime(n):
	for i in range(2, int(math.sqrt(n)) + 1):
		if n % i == 0:
			return False
	return True
for i in range(1, int(1000000000.0)):
	if not prime(a * i + 1):
		print(i)
		break


n = int(input())
from math import sqrt
for i in range(1, 1001):
	t = n * i + 1
	for m in range(2, int(sqrt(t)) + 1):
		if t % m == 0:
			print(i)
			exit()


import sys
from math import sqrt, floor, factorial
from collections import deque, Counter
inp = sys.stdin.readline
read = lambda : list(map(int, inp().strip().split()))

def is_prime(n):
	for i in range(2, int(sqrt(n)) + 1):
		if not n % i:
			return False
	return True

def solve():
	n = int(inp())
	if n % 2 == 1 and n != 1:
		print(1)
	else:
		for m in range(1, 10 ** 3 + 1):
			if not is_prime(n * m + 1):
				print(m)
				break
solve()


def isprime(n):
	if n == 1:
		return False
	for i in range(2, n):
		if n % i == 0:
			return False
	return True
n = int(input())
m = 1
while 1:
	a = n * m + 1
	if isprime(a):
		m += 1
	else:
		print(m)
		break


n = int(input())
m = 1
ch = 1
while ch == 1:
	l = n * m + 1
	for i in range(3, l // 2 + 1):
		if l % i == 0 and i != l:
			ch = 0
			break
	else:
		m += 1
print(m)


def is_prime(a):
	for i in range(2, int(pow(a, 0.5) + 1)):
		if a % i == 0:
			return 1
	return 0
n = int(input())
if n % 2:
	print(3)
else:
	m = 1
	while True:
		if is_prime(m * n + 1):
			break
		m += 1
	print(m)


a = int(input())
if a < 990:
	print(a + 2)
else:
	print(a - 2)


arr = [True] * 10 ** 6

def sieve():
	for i in range(2, 10 ** 6):
		if arr[i]:
			for j in range(i * 2, 10 ** 6, i):
				arr[j] = False
sieve()
n = int(input())
i = 0
while True:
	i += 1
	if not arr[i * n + 1]:
		print(i)
		exit(0)


def eh_primo(n):
	for i in range(2, n):
		if n % i == 0:
			return False
	return True

def numero(n, m):
	if not eh_primo(n * m + 1):
		return m
	return numero(n, m + 1)
n = int(input())
print(numero(n, 1))


def isNotPrime(x):
	for i in range(2, x):
		if x % i == 0:
			return True
	return False
n = int(input())
m = 1
while True:
	if isNotPrime(n * m + 1):
		print(m)
		break
	else:
		m += 1


n = int(input())
m = 1
if n % 2 == 0 or n == 1:
	for i in range(2, 100):
		for j in range(2, (n * i + 1) // 2 + 1):
			if (n * i + 1) % j == 0:
				m = i
				break
		if m != 1:
			break
print(m)


n = int(input())
if n < 998:
	print(n + 2)
else:
	print(n - 2)


n = int(input())
k = 1
flag = 1
m = n
while flag:
	m = m * k + 1
	for i in range(2, m):
		if m % i == 0:
			print(k)
			flag = 0
			break
	k += 1
	m = n


def check_prime(num):
	j = 2
	while j * j <= num:
		if num % j == 0:
			return False
		j += 1
	return True

def solve():
	n = int(input())
	for m in range(1, 1001):
		num = n * m + 1
		if check_prime(num) == False:
			print(m)
			return
solve()


n = int(input())
flag = True
m = 1
a = [True] * 1000001
a[1] = False
for i in range(2, len(a)):
	if a[i]:
		for j in range(2 * i, len(a), i):
			a[j] = False
while flag:
	if a[m * n + 1] == False:
		flag = False
		print(m)
	else:
		m += 1


n = int(input())
a = 0
b = False
while not b:
	a += 1
	c = a * n + 1
	for i in range(2, int(c ** 0.5) + 1):
		if c % i == 0:
			b = True
			print(a)
			break


def prime(x):
	for i in range(2, x):
		if x % i == 0:
			return False
	return True
j = int(input())
i = 1
while True:
	if prime(j * i + 1) == True:
		i += 1
	else:
		print(i)
		exit()


def check_if_prime(num):
	if num == 1 or num == 2:
		return True
	for i in range(2, num):
		if num % i == 0:
			return False
	return True

def codeforces(num):
	cand = 1
	while True:
		if not check_if_prime(num * cand + 1):
			return cand
		cand += 1
num = int(input())
print(codeforces(num))


a = int(input())
print([a + 2, a - 2][a > 998])


n = int(input())

def prime(n):
	for i in range(2, n):
		if n % i == 0:
			return i
	return 0
for i in range(1, 1000):
	if prime(n * i + 1) != 0:
		print(i)
		break


def p(n):
	c = int(n ** 0.5) + 2
	d = 0
	for i in range(2, c):
		if n % i == 0:
			d = 1
			break
	return d
x = int(input())
if x == 1:
	print(3)
	exit(0)
if x == 2:
	print(4)
	exit(0)
for i in range(1, 100 * x + 1):
	cp = x * i + 1
	if p(cp) == 1:
		print(i)
		exit(0)


import math

def isPrime(n):
	for i in range(2, math.floor(math.sqrt(n)) + 1):
		if n % i == 0:
			return True
	return False

def solve(n):
	total = n + 1
	if isPrime(total):
		return 1
	for i in range(1, 1000):
		if isPrime(n * i + 1):
			return i
n = int(input())
print(solve(n))


n = int(input())
k = 0

def isprime(x):
	s = 0
	for i in range(2, x + 1):
		if x % i == 0:
			s = s + 1
	if s <= 1:
		return True
while True:
	k = k + 1
	v = n * k + 1
	if isprime(v) == True:
		continue
	else:
		print(k)
		break


def is_prime(x):
	if x % 2 == 0 and x != 2 or x == 1:
		return 0
	y = 3
	while y * y <= x:
		if x % y == 0:
			return 0
		y += 2
	return 1
n = int(input())
for i in range(1, 1001):
	if not is_prime(n * i + 1):
		print(i)
		break


def iscomposite(N):
	i = 2
	while i * i <= N:
		if N % i == 0:
			return True
		i += 1
(n,) = [int(i) for i in input().split()]
for i in range(1, 1001):
	if iscomposite(n * i + 1):
		print(i)
		break


import sys
n = int(input())

def isPrime(x, primes):
	for p in primes:
		if x > p and x % p == 0:
			return False
	primes.append(x)
	return True
primes = []
for i in range(2, 1000, 1):
	isPrime(i, primes)
for m in range(1, 1000, 1):
	if not isPrime(n * m + 1, primes):
		print(m)
		exit()


import sys
import math
import bisect
import itertools
import random

def pow_mod(a, n, m):
	if n == 0:
		return 1
	if n == 1:
		return a % m
	ans = pow_mod(a, n // 2, m)
	ans = ans * ans % m
	if n % 2 == 1:
		ans = ans * a % m
	return ans

def MillerRabin_PrimalityTesting(n):
	if n == 2 or n == 3:
		return True
	if n % 2 == 0:
		return False
	if n % 3 == 0:
		return False
	R = 0
	D = n - 1
	while D % 2 == 0:
		R += 1
		D //= 2
	for _ in range(random.randint(10, 15)):
		A = random.randint(2, n - 1)
		X = pow_mod(A, D, n)
		if X == 1 or X == n - 1:
			continue
		flag = 0
		for i in range(1, R):
			X = pow_mod(X, 2, n)
			if X == 1:
				return False
			if X == n - 1:
				flag = 1
				break
		if flag == 1:
			continue
		return False
	return True

def main():
	n = int(input())
	for i in range(1, 1001):
		val = n * i + 1
		if MillerRabin_PrimalityTesting(val) == False:
			print(i)
			break
main()


import math
n = int(input())
for i in range(1, 10 ** 3 + 1):
	a = n * i + 1
	if math.factorial(a - 1) % a == (a - 1) % a or math.factorial(a - 1) == -1 % a:
		continue
	else:
		print(i)
		break


n = int(input())
l = 1
for i in range(2, 10 ** 3 + 1):
	if l == 1:
		for y in range(2, int((i * n + 1) ** 0.5) + 2):
			if (i * n + 1) % y == 0:
				print(i)
				l = 0
				break
	else:
		break


n = int(input())

def isPrime(x):
	for j in range(2, round(x ** 0.5) + 1):
		if not x % j:
			return False
	return True
for m in range(1, 1000):
	if not isPrime(m * n + 1):
		print(m)
		break


def is_prime(number):
	for div in range(2, number // 2 + 1):
		if number % div == 0:
			return False
	return True
n = int(input())
for m in range(1, 1001):
	if not is_prime(n * m + 1):
		print(m)
		break


def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True
n = int(input())
i = 1
if n == 1:
	print(5)
elif n % 2 != 0:
	print(n)
else:
	while isPrime(n * i + 1):
		i += 1
	print(i)


from math import *

def ifprime(n):
	f = 0
	for i in range(2, int(sqrt(n)) + 1):
		if n % i == 0:
			f = 1
			break
	if f == 0:
		return True
	return False
n = int(input())
m = 1
while 1:
	if not ifprime(n * m + 1):
		print(m)
		break
	m += 1


from math import sqrt

def prime(n):
	for i in range(2, int(sqrt(n)) + 1):
		if n % i == 0:
			return 0
	return 1

def number(n):
	for i in range(1, 1001):
		if prime(i * n + 1) == 0:
			return i
n = int(input())
x = number(n)
print(x)


n = int(input())
if n == 2:
	print(4)
elif n == 1:
	print(3)
elif n % 2:
	print(1)
else:
	for i in range(3, 37, 2):
		k = n % i
		if not k:
			pass
		else:
			for j in range(1, i + 1):
				if not (n * j + 1) % i:
					print(j)
					exit(0)


n = int(input())
m = 1
while True:
	mul = m * n + 1
	for i in range(2, int((m * n + 1) ** 0.5) + 1):
		if mul % i == 0:
			print(m)
			exit()
	m += 1


n = int(input())
m = 1
if n <= 2:
	print(2 + n)
elif n % 2 == 1:
	print(1)
else:
	print(n - 2)


def prime(n):
	for i in range(2, n):
		if n % i == 0:
			return False
	return True
n = int(input())
if n == 1:
	print(3)
elif n % 2:
	print(1)
else:
	i = 1
	while True:
		if prime(n * i + 1):
			i += 1
		else:
			print(i)
			exit()


import sys
input = sys.stdin.readline

def is_prime(num):
	if num < 2:
		return False
	elif num == 2:
		return True
	for i in range(2, int(num ** 0.5) + 1):
		if num % i == 0:
			return False
	return True
n = int(input())
m = 1
while True:
	x = n * m + 1
	if not is_prime(x):
		print(m)
		break
	m += 1


def isPrime(x):
	if x < 2:
		return False
	for i in range(2, x):
		if x % i == 0:
			return False
	return True
n = int(input())
for i in range(1, 1001):
	if not isPrime(n * i + 1):
		print(i)
		break


from __future__ import division, print_function
from fractions import Fraction
import sys
import os
from io import BytesIO, IOBase
from itertools import *
import bisect
from heapq import *
from math import *
from copy import *
from collections import deque
from collections import Counter as counter
from itertools import combinations as comb
from itertools import permutations as permutate
from bisect import bisect_left as bl
from bisect import bisect_right as br
from bisect import bisect
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
from types import GeneratorType

def iterative(f, stack=[]):

	def wrapped_func(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		to = f(*args, **kwargs)
		while True:
			if type(to) is GeneratorType:
				stack.append(to)
				to = next(to)
				continue
			stack.pop()
			if not stack:
				break
			to = stack[-1].send(to)
		return to
	return wrapped_func
mod = 1000000007

def inp():
	return sys.stdin.readline().rstrip('\r\n')

def out(var):
	sys.stdout.write(str(var))

def lis():
	return list(map(int, inp().split()))

def stringlis():
	return list(map(str, inp().split()))

def sep():
	return map(int, inp().split())

def strsep():
	return map(str, inp().split())

def zerolist(n):
	return [0] * n

def nextline():
	out('\n')

def testcase(t):
	for p in range(t):
		solve()

def printlist(a):
	for p in range(0, len(a)):
		out(str(a[p]) + ' ')

def gcd(a, b):
	if a == b:
		return a
	while b > 0:
		(a, b) = (b, a % b)
	return a

def lcm(a, b):
	return abs(a // gcd(a, b) * b)

def primesbelow(N):
	correction = N % 6 > 1
	N = {0: N, 1: N - 1, 2: N + 4, 3: N + 3, 4: N + 2, 5: N + 1}[N % 6]
	sieve = [True] * (N // 3)
	sieve[0] = False
	for i in range(int(N ** 0.5) // 3 + 1):
		if sieve[i]:
			k = 3 * i + 1 | 1
			sieve[k * k // 3::2 * k] = [False] * ((N // 6 - k * k // 6 - 1) // k + 1)
			sieve[(k * k + 4 * k - 2 * k * (i % 2)) // 3::2 * k] = [False] * ((N // 6 - (k * k + 4 * k - 2 * k * (i % 2)) // 6 - 1) // k + 1)
	return [2, 3] + [3 * i + 1 | 1 for i in range(1, N // 3 - correction) if sieve[i]]
smallprimeset = set(primesbelow(100000))

def solve():
	n = int(inp())
	for i in range(1, 2000):
		if n * i + 1 not in smallprimeset:
			ans = i
			break
	print(ans)
solve()


def is_prime(n):
	if n in (2, 3, 5):
		return True
	for i in range(2, int(n ** 0.5) + 1):
		if n % i == 0:
			return False
	return True
n = int(input())
for i in range(1, 1000):
	if not is_prime(n * i + 1):
		print(i)
		break


def checkPrime(num):
	if num > 1:
		for i in range(2, num):
			if num % i == 0:
				return False
		else:
			return True
	else:
		return False
inp = int(input())
if inp % 2 == 1:
	if inp == 1:
		print(3)
	else:
		print(1)
else:
	m = 1
	for i in range(1, 1000):
		m = i
		if not checkPrime(inp * m + 1):
			break
	print(m)


n = int(input())
status = m = 1
if n % 2 == 1:
	if n == 1:
		print(3)
	else:
		print(1)
elif n == 2:
	print(4)
else:
	print(n - 2)


n = int(input())
if n == 2:
	print(4)
elif n % 2 == 0 and n != 2:
	print(n - 2)
elif n == 1:
	print(3)
else:
	print(1)


def isNotPrime(k):
	for j in range(2, int(k ** (1 / 2)) + 1):
		if k % j == 0:
			return True
	return False
n = int(input())
if n % 2 != 0:
	m = 1
else:
	for i in range(1, 10000):
		if isNotPrime(n * i + 1):
			m = i
			break
if n == 1:
	m = 3
print(m)


n = int(input())
ans = 0
for i in range(1, 1001):
	t = n * i + 1
	for j in range(2, t):
		if t % j == 0:
			ans = i
	if ans != 0:
		break
print(ans)


import math

def is_prime(n):
	if n % 2 == 0 and n > 2:
		return False
	return all((n % i for i in range(3, int(math.sqrt(n)) + 1, 2)))
n = int(input())
m = 1
while is_prime(n * m + 1):
	m += 1
print(m)


n = int(input())
print(n - 2 + 4 * int(n < 3))


from math import factorial as fal
n = int(input())
k = 0
i = 1
while 1:
	k = n * i + 1
	if fal(k - 1) % k != k - 1:
		print(i)
		break
	i += 1


import math

def prime(n):
	test = 0
	for i in range(2, math.ceil(n ** 0.5) + 1):
		if n % i == 0:
			test = 1
			break
	if test:
		return False
	return True
n = int(input())
if n == 1:
	print(3)
else:
	i = 1
	x = n * i + 1
	while prime(x):
		i += 1
		x = n * i + 1
	print(i)


def composite(x):
	for i in range(2, x):
		if x % i == 0:
			y = x
			return y
n = int(input())
if n == 1:
	print(3)
	exit()
elif n == 2:
	print(4)
	exit()
elif n == 0 or n == 6:
	print(4)
	exit()
for i in range(1, n, 1):
	if n * i + 1 == composite(n * i + 1):
		print(i)
		break


n = int(input())
if n == 1:
	print(5)
elif n == 2:
	print(4)
else:
	print(n - 2)


from random import randint

def is_prime(n):
	if n == 1:
		return False
	for i in range(2, int(n ** 0.5) + 1):
		if n % i == 0:
			return False
	return True
n = int(input())
m = 1
if n == 1 or n % 2 == 0:
	while is_prime(m * n + 1):
		m = randint(1, 1000)
print(m)


from math import *
from copy import *
from string import *
from random import *
from sys import stdin
from sys import maxsize
from operator import *
from itertools import *
from collections import Counter
import math
n = int(input())
if n == 1:
	print(9)
elif n % 2 != 0:
	print(n)
elif n == 1000:
	print(1)
else:
	print(n + 2)


prime = []
numberlist = []
for i in range(2, 1001):
	numberlist.append(i)
while numberlist[0] < 32:
	now = numberlist.pop(0)
	prime.append(now)
	newnumberlist = []
	for i in range(0, len(numberlist)):
		if numberlist[i] % now != 0:
			newnumberlist.append(numberlist[i])
	numberlist = newnumberlist
prime = prime + newnumberlist
N = int(input())
flag = False
for i in range(1, 1001):
	X = N * i + 1
	if X <= 1000:
		if X not in prime:
			print(i)
			break
	else:
		flag = False
		for j in range(0, len(prime)):
			if X % prime[j] == 0:
				flag = True
				print(i)
				break
		if flag:
			break


x = int(input())
if x >= 999:
	print(x - 2)
else:
	print(x + 2)


import math
n = int(input())
ko = 1000 * 1000 + 1
arrnum = [False for arrnum in range(0, ko)]
for i in range(2, ko):
	if not arrnum[i]:
		for j in range(i + i, ko, i):
			arrnum[j] = True
m = 1
while not arrnum[n * m + 1]:
	m += 1
print(m)


n = int(input())
hash = [0] * 100000
primes = set()
for i in range(2, 10 ** 5):
	if hash[i] == 0:
		primes.add(i)
		for j in range(i, 10 ** 5, i):
			hash[j] = 1
for m in range(1, 1000 + 1):
	if n * m + 1 not in primes:
		print(m)
		exit()


a = int(input())
b = []
for i in range(1, 10):
	c = i * a + 1
	for x in range(2, c):
		if c % x == 0:
			b.append(i)
			break
print(min(b))


import math

def naoPrimo(num):
	for i in range(2, int(math.sqrt(num) + 1)):
		if num % i == 0:
			return False
	return True
entrada = int(input())
m = 1
while m >= 1:
	primo = entrada * m + 1
	if naoPrimo(primo) == False:
		print(m)
		break
	else:
		m += 1
		naoPrimo(primo)


def prime(N):
	count = 0
	i = 1
	while i * i <= N:
		if i * i == N:
			count = count + 1
		elif N % i == 0:
			count = count + 2
		if count > 2:
			return 0
		i = i + 1
	if count == 2:
		return 1
	else:
		return 0
n = int(input())
for m in range(1, 1001):
	t = prime(n * m + 1)
	if t == 0:
		print(m)
		break


n = int(input())

def f(n):
	if n < 3:
		return n + 2
	for q in [2, 3, 5, 7, 11]:
		s = n % q
		if s:
			for m in range(1, q):
				if not (s * m + 1) % q:
					return m
print(f(n))


import sys

def prime_factors(n):
	i = 2
	factors = []
	while i * i <= n:
		if n % i:
			i += 1
		else:
			n //= i
			factors.append(i)
	if n > 1:
		factors.append(n)
	return factors
primes = [2, 3, 5, 7, 11, 13, 17, 19, 23]
n = int(input())
factors = prime_factors(n)
l = min(list(set(primes) - set(factors)))
for m in range(1000):
	if (n * m + 1) % l == 0 and n * m + 1 != l:
		print(m)
		sys.exit()


n = int(input())
for m in range(1, 1000):
	num_test = m * n + 1
	for i in range(2, int(num_test / 2) + 1):
		if num_test % i == 0:
			print(m)
			break
	else:
		continue
	break


def isprime(n):
	if n <= 1:
		return False
	for i in range(2, int(n ** 0.5) + 1):
		if n % i == 0:
			return False
	return True
n = int(input())
if n & 1 and n != 1:
	print(1)
else:
	ans = 1
	for i in range(n + 1):
		c = n * (i + 1) + 1
		if isprime(c):
			ans += 1
		else:
			break
	print(ans)


n = int(input())
for m in range(1, 1000):
	primeCandidate = n * m + 1
	isPrime = True
	for i in range(2, primeCandidate):
		if primeCandidate % i == 0:
			isPrime = False
			break
	if not isPrime:
		print(m)
		break


def prime(n):
	if n < 2:
		return True
	if n == 2:
		return False
	for i in range(2, int(n ** 0.5) + 2):
		if n % i == 0:
			return True
	return False
n = int(input())
m = 1
while True:
	if prime(n * m + 1):
		print(m)
		break
	m = m + 1


n = int(input())
if n % 2 == 1:
	print(1 if n > 1 else 3)
else:
	for m in range(1000):
		val = n * m + 1
		if val in [3, 5, 7, 11, 13, 17]:
			continue
		if val % 3 == 0 or val % 5 == 0 or val % 7 == 0 or (val % 11 == 0) or (val % 13 == 0) or (val % 17 == 0):
			print(m)
			break


n = int(input())
k = 0
for i in range(1, 1001):
	for j in range(1, i * n + 2):
		if (i * n + 1) % j == 0:
			k += 1
	if k > 2:
		print(i)
		exit()
	k = 0


n = int(input())

def prime(x):
	for i in range(2, x):
		if x % i == 0:
			return False
	else:
		return True
for j in range(1, 10):
	if not prime(n * j + 1):
		print(j)
		break
	else:
		continue


n = int(input())
cnt = 17
while True:
	m = n * cnt + 1
	if m % 2 == 0 or m % 3 == 0 or m % 5 == 0 or (m % 7 == 0) or (m % 11 == 0) or (m % 13 == 0) or (m % 17 == 0):
		break
	cnt += 1
print(cnt)


n = int(input())
from math import sqrt

def is_prime(n):
	if n < 2:
		return False
	if n == 2:
		return True
	if n % 2 == 0:
		return False
	limit = sqrt(n)
	i = 2
	while i <= limit:
		if n % i == 0:
			return False
		i += 1
	return True
if n % 2 != 0 and n != 1:
	print(1)
elif n == 1:
	print(3)
else:
	for m in range(1, 120):
		if not is_prime(n * m + 1):
			print(m)
			break


def main():
	N = int(input())
	for m in range(1, 1001):
		j = 2
		flag = True
		num = N * m + 1
		while j * j <= num:
			if num % j == 0:
				flag = False
				break
			j += 1
		if flag == False:
			print(m)
			break
main()


n = int(input())
for i in range(1, 1000):
	flag = False
	for j in range(2, int((n * i + 1) ** 0.5 + 1)):
		if (n * i + 1) % j == 0:
			flag = True
	if flag:
		print(i)
		break


prime = []
for i in range(2, 4000):
	prime.append(i)
for i in range(2, 4000):
	for j in range(i + i, 4000, i):
		if j in prime:
			prime.remove(j)
n = int(input())
for m in range(1, 1001):
	if n * m + 1 not in prime:
		print(m)
		break


import random, math

def test_simple(num):
	for i in range(2, min(num, int(math.sqrt(num) + 2))):
		if num % i == 0:
			return False
	return True
n = int(input())
for i in range(1, 1001):
	if not test_simple(n * i + 1):
		print(i)
		break


def prime_t(t):
	i = 2
	while i ** 2 <= t:
		if t % i == 0:
			return 0
		i += 1
	return 1

def prime_list(tt):
	p_list = []
	for i in range(2, tt + 1):
		if prime_t(i):
			p_list.append(i)
	return p_list
chk = prime_list(10001)
n = int(input())
if n + 1 in chk:
	for i in chk:
		if n * i + 1 not in chk:
			print(i)
			break
else:
	print(1)


import random
_mrpt_num_trials = 5

def is_probable_prime(n):
	assert n >= 2
	if n == 2:
		return True
	if n % 2 == 0:
		return False
	s = 0
	d = n - 1
	while True:
		(quotient, remainder) = divmod(d, 2)
		if remainder == 1:
			break
		s += 1
		d = quotient
	assert 2 ** s * d == n - 1

	def try_composite(a):
		if pow(a, d, n) == 1:
			return False
		for i in range(s):
			if pow(a, 2 ** i * d, n) == n - 1:
				return False
		return True
	for i in range(_mrpt_num_trials):
		a = random.randrange(2, n)
		if try_composite(a):
			return False
	return True
n = int(input())
if n % 2 != 0:
	print('3')
else:
	for i in range(1, 100):
		if not is_probable_prime(n * i + 1):
			print(i)
			break


def chechk(ed):
	for i in range(2, int(ed ** 0.5) + 1):
		if ed % i == 0:
			return False
	return True
n = int(input())
m = 1
while True:
	if not chechk(n * m + 1):
		break
	m += 1
print(m)


import math

def noprost(s):
	for i in range(2, int(math.sqrt(s) + 1)):
		if s % i == 0:
			return True
	return False
n = int(input())
j = 0
while True:
	j += 1
	if noprost(n * j + 1):
		print(j)
		break


n = int(input())

def isprime(z):
	for i in range(2, int(z ** 0.5) + 1):
		if z % i == 0:
			return False
	else:
		return True
for m in range(1, n + 3):
	if isprime(n * m + 1) == False:
		print(m)
		break


def main():
	n = int(input())
	print(3 if n == 1 else 4 if n == 2 else n - 2)
main()


def isPrime(n):
	c = 0
	for i in range(2, n // 2):
		if n % i == 0:
			c = 1
			break
	if c == 0:
		return True
	return False
n = int(input())
if n == 1:
	print(3)
elif n == 2:
	print(4)
else:
	for i in range(1, n):
		if (n * i + 1) % 2 == 0:
			print(i)
			break
		elif not isPrime(n * i + 1):
			print(i)
			break


n = int(input())
m = 1
a = True
while a:
	k = n * m + 1
	for i in range(2, k):
		if k % i == 0:
			print(m)
			a = False
			break
	else:
		m += 1


providedNumber = int(input())
foundNumber = 1

def isPrime(number):
	for i in range(2, number):
		if number % i == 0:
			return False
	return True
while isPrime(providedNumber * foundNumber + 1):
	foundNumber += 1
print(foundNumber)


n = int(input())
prime_no = []
for i in range(2, 100001):
	flag = 0
	for j in range(2, int(i ** (1 / 2)) + 1):
		if i % j == 0:
			flag = 1
			break
	if flag == 0:
		prime_no.append(i)
for m in range(1, 1001):
	if n * m + 1 not in prime_no:
		print(m)
		break


def pprime(p):
	i = 2
	while i * i <= p:
		if p % i == 0:
			return False
		i += 1
	return True
n = int(input())
if n == 1:
	print(3)
elif n % 2 == 0:
	for i in range(1, 1001):
		if pprime(n * i + 1) == False:
			print(i)
			break
else:
	print(1)


from math import sqrt
from math import floor
n = int(input())

def prime(n):
	for i in range(2, floor(sqrt(n)) + 1, 1):
		if n % i == 0:
			return False
	return True
for m in range(1, 1000, 1):
	if not prime(n * m + 1):
		print(m)
		break


x = int(input())
if x - 2 < 1:
	print(x + 2)
else:
	print(x - 2)


n = int(input())
if n % 2 != 0:
	if n != 1:
		print(1)
	else:
		print(3)
elif n == 2:
	print(7)
else:
	print(n - 2)


def foo(n):
	if n == 1:
		print(3)
		quit()
	if n == 2:
		print(4)
		quit()
	if n % 2 == 1:
		print(1)
	else:
		print(n - 2)
a = int(input())
foo(a)


def isNotPrime(x):
	if x < 4:
		return False
	if x % 2 == 0:
		return True
	for div in range(2, x):
		if x % div == 0:
			return True
	return False

def findM(n, m):
	prime = n * m + 1
	if isNotPrime(prime):
		return m
	return findM(n, m + 1)
n = int(input())
print(findM(n, 1))


n = int(input())
m = 1
z = True
while z:
	x = n * m + 1
	for i in range(2, x):
		if x % i == 0:
			print(m)
			z = False
			break
	m += 1


n = int(input())
if n == 1:
	print(8)
elif n == 2:
	print(4)
else:
	print(n - 2)


def prime(n):
	for i in range(2, int(n ** (1.0 / 2.0)) + 1):
		if n % i == 0:
			return False
	return True
n = int(input())
for i in range(1, 1001):
	if prime(n * i + 1) == False:
		print(i)
		break


n = int(input())
if n == 1:
	print(n + 2)
elif n == 2:
	print(n * 2)
elif n > 2:
	print(n - 2)


primes = [int(i) for i in '2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97 101'.split()]
n = int(input())
if n == 1:
	print(3)
elif n == 2:
	print(10)
else:
	for i in primes:
		if n % i != 0:
			k = i
			break
	for i in range(k):
		if (n * (i + 1) + 1) % k == 0:
			print(i + 1)


from sys import stdin
from collections import deque
from math import sqrt, floor, ceil, log, log2, log10, pi, gcd, sin, cos, asin

def ii():
	return int(stdin.readline())

def fi():
	return float(stdin.readline())

def mi():
	return map(int, stdin.readline().split())

def fmi():
	return map(float, stdin.readline().split())

def li():
	return list(mi())

def lsi():
	x = list(stdin.readline())
	x.pop()
	return x

def si():
	return stdin.readline()

def sieve(x):
	a = [True] * (x + 1)
	sq = floor(sqrt(x))
	for i in range(2, sq + 1):
		if a[i]:
			for j in range(i * i, x + 1, i):
				a[j] = False
	return a
p = sieve(1000008)
n = ii()
for i in range(1, 1001):
	if not p[n * i + 1]:
		print(i)
		exit()


def prinme(n):
	for i in range(2, n):
		if n % i == 0:
			return i
	return n
n = int(input())
i = 1
while True:
	if prinme(n * i + 1) != n * i + 1:
		print(i)
		break
	i += 1


P = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37}
n = int(input())
if n == 1:
	print(3)
else:
	for p in P:
		done = False
		if n % p != 0:
			r = 1
			for i in range(1, 2 * p):
				r += n
				if r > p and r % p == 0:
					print(i)
					done = True
					break
		if done:
			break


n = int(input())
if n % 2 == 1:
	print(3)
else:
	flag = False
	for i in range(1, 1000):
		p = i * n + 1
		for j in range(2, p):
			if p % j == 0:
				print(i)
				flag = True
				break
		if flag:
			break


import sys
import math
get_string = lambda : sys.stdin.readline().strip()
get_int_list = lambda : list(map(int, sys.stdin.readline().strip().split()))
get_intList_from_str = lambda : list(map(int, list(sys.stdin.readline().strip())))
get_charList_from_str = lambda : list(sys.stdin.readline().strip())
get_char_list = lambda : sys.stdin.readline().strip().split()
get_int = lambda : int(sys.stdin.readline())
pt = lambda x: sys.stdout.write(str(x))

def isprime(n):
	i = 2
	while i * i <= n:
		if n % i == 0:
			return False
		i += 1
	return True
n = get_int()
i = 1
while True:
	if not isprime(n * i + 1):
		print(i)
		break
	i += 1


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, copy, functools
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return list(map(int, sys.stdin.readline().split()))

def LLI():
	return [tuple(map(int, l.split())) for l in sys.stdin]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

class Prime:

	def __init__(self, n):
		self.M = m = int(math.sqrt(n)) + 10
		self.A = a = [True] * m
		a[0] = a[1] = False
		self.T = t = []
		for i in range(2, int(math.sqrt(m)) + 1):
			if not a[i]:
				continue
			t.append(i)
			for j in range(i * i, m, i):
				a[j] = False

	def is_prime(self, n):
		return self.A[n]

	def division(self, n):
		d = collections.defaultdict(int)
		for c in self.T:
			while n % c == 0:
				d[c] += 1
				n //= c
			if n < 2:
				break
		if n > 1:
			d[n] += 1
		return d.items()

	def sowa(self, n):
		r = 1
		for (k, v) in self.division(n):
			t = 1
			for i in range(1, v + 1):
				t += math.pow(k, i)
			r *= t
		return r

def main():
	n = I()
	pr = Prime(10 ** 7)
	for i in range(1, 1001):
		if not pr.is_prime(n * i + 1):
			return i
	return -1
print(main())


n = int(input())
if n > 2:
	print(n - 2)
elif n == 2:
	print(12)
else:
	print(9)


def es_primo(a):
	if a == 1:
		return False
	elif a == 2:
		return True
	for i in range(2, a):
		if a % i == 0:
			return False
	return True
n = int(input())
m = 1
while es_primo(n * m + 1):
	m = m + 1
print(m)


n = int(input())
if n != 1:
	if n % 2 == 1:
		print('1')
	else:
		if n % 5 == 1:
			print('4')
		if n % 5 == 2:
			print('7')
		if n % 5 == 3:
			print('3')
		if n % 5 == 4:
			print('6')
		if n % 5 == 0:
			i = 1
			k = 2
			while k < n * i + 1:
				if (n * i + 1) % k == 0:
					print(i)
					break
				k += 1
				if k == n * i + 1:
					k = 2
					i += 1
if n == 1:
	print('3')


import math

def isPrime(n):
	for i in range(2, int(math.sqrt(n)) + 1):
		if n % i == 0:
			return False
	return True
n = int(input())
for i in range(1, 1001):
	if isPrime(n * i + 1) == False:
		print(i)
		break


from math import sqrt

def isPrime(n):
	for i in range(2, int(sqrt(n)) + 1):
		if n % i == 0:
			return True
	return False
n = int(input())
if n == 1:
	m = 3
elif n == 2:
	m = 4
elif n % 2 != 0:
	m = 1
else:
	m = 1
	verdict = isPrime(n * m + 1)
	while not verdict:
		m += 1
		verdict = isPrime(n * m + 1)
print(m)


def is_prime(x):
	if x == 0 or x == 1:
		return False
	else:
		for i in range(2, x):
			if x % i == 0:
				return False
	return True
n = int(input())
for i in range(1, 1001):
	if not is_prime(n * i + 1):
		print(i)
		break


t = int(input())

def isprime(kek):
	ls = True
	for i in range(2, int(kek ** 0.5) + 1):
		if kek % i == 0:
			ls = False
			break
	return ls
if t != 1:
	for i in range(1, 10 ** 3):
		if isprime(i * t + 1) == False:
			print(i)
			break
else:
	print(3)


n = int(input())

def isgood(x):
	for j in range(2, x - 1):
		if x % j == 0:
			return False
	return True
for i in range(1000):
	if not isgood(n * i + 1):
		print(i)
		break


n = int(input())
if n % 2 == 1:
	print('{}'.format(3))
elif n == 2:
	print('{}'.format(n + 2))
else:
	print('{}'.format(n - 2))


import math

def isp(n):
	if n == 2:
		return True
	for i in range(2, int(math.sqrt(n) + 1) + 1):
		if n % i == 0:
			return False
	return True

def main():
	n = int(input())
	for i in range(1, 10 ** 6):
		if not isp(i * n + 1):
			print(i)
			break
main()


def main():
	import itertools

	def is_prime(x):
		if x == 2:
			return True
		if x & 1 == 0:
			return False
		i = 3
		while i * i <= x:
			if x % i == 0:
				return False
			i += 2
		return True
	try:
		while True:
			n = int(input())
			for m in itertools.count(1):
				if not is_prime(n * m + 1):
					print(m)
					break
	except EOFError:
		pass
main()


import math

def prime(x):
	p = [0] * int(pow(x, 1 / 2) - 1)
	for i in range(2, int(pow(x, 1 / 2) + 1)):
		if x % i != 0:
			p[i - 2] = 0
		else:
			p[i - 2] = 1
	if p.count(1) == 0:
		return 1
	else:
		return 0
n = int(input())
m = 1
while prime(n * m + 1):
	m += 1
print(m)


n = int(input())
if n < 100:
	print(n + 2)
else:
	print(n - 2)


def f(n):
	for i in range(3, n // 2 + 1, 2):
		if n % i == 0:
			return False
	return True
n = int(input())
if n == 1:
	print(3)
elif n % 2:
	print(1)
else:
	q = 1
	while f(n * q + 1):
		q += 1
	print(q)


q = int(input())
if q % 2 != 0:
	if q == 1:
		print('8')
	else:
		print('1')
elif q + 2 >= 1000:
	print(q - 2)
else:
	print(q + 2)


n = int(input())
print(3 if n is 1 else 4 if n is 2 else n - 2)


n = int(input())

def is_prime(n):
	i = 2
	while i * i <= n:
		if n % i == 0:
			return False
		i += 1
	return True
if n % 2 == 1:
	print(3)
else:
	for i in range(1, 10 ** 3):
		if not is_prime(n * i + 1):
			print(i)
			exit()


from math import *

def prime(a):
	for j in range(2, min(ceil(sqrt(a)) + 1, a)):
		if a % j == 0:
			return False
	return True
a = int(input())
for j in range(1, 1000 + 1):
	if not prime(a * j + 1):
		print(j)
		break


n = int(input())
if n == 1:
	print(3)
	exit(0)

def is_prime(n):
	return False if n % 2 == 0 else all((n % i for i in range(3, int(n ** 0.5) + 1, 2)))
for m in range(1, 1001):
	if not is_prime(n * m + 1):
		print(m)
		break


n = int(input())
from math import sqrt
from itertools import count, islice
from sys import exit

def isPrime(n):
	return n > 1 and all((n % i for i in islice(count(2), int(sqrt(n) - 1))))
if n > 2 and n % 2 == 1:
	print(1)
	exit()
else:
	m = 1.0
	while isPrime(n * m + 1.0):
		m += 1.0
	print(int(m))
	exit()


n = int(input())
a = [True for i in range(1000002)]
a[1] = False
for i in range(2, 1000002):
	if a[i]:
		for j in range(i * 2, 1000002, i):
			a[j] = False
m = 1
while a[n * m + 1]:
	m += 1
print(m)


n = 10000

def sieve():
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p]:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	primes = []
	for i in range(2, n + 1):
		if prime[i]:
			primes.append(i)
	return primes
t = int(input())
x = sieve()
for m in range(1, 1001):
	if t * m + 1 not in x:
		print(m)
		break


def isPrime(number):
	s = int(number ** 1 / 2)
	while s > 1:
		if number % s == 0:
			return False
		s -= 1
	return True
n = int(input())
m = 1
while True:
	k = n * m + 1
	if not isPrime(k):
		print(m)
		break
	m += 1


def is_prime(n):
	divisors = 0
	if n == 2:
		return True
	for i in range(1, int(n ** 1 / 2) + 1):
		if n % i == 0:
			divisors += 1
		if divisors > 1:
			return False
	return True

def solution(n):
	for m in range(1, 1001):
		if not is_prime(n * m + 1):
			return m
n = int(input())
print(solution(n))


N = int(input())
if N == 1:
	print(3)
	exit(0)
if N % 2 == 1:
	print(1)
	exit(0)
for m in range(1, 1001):
	num = N * m + 1
	fl = 0
	for i in range(2, int(num ** 0.5) + 1):
		if num % i == 0:
			fl = 1
	if fl:
		print(m)
		break


n = int(input())
if n % 2:
	print(3)
else:
	import math
	m = 1
	while True:
		b = 0
		num = n * m + 1
		for x in range(1, int(math.sqrt(num) + 1)):
			if not num % x:
				b += 1
		if b != 1:
			print(m)
			break
		m += 1


num = int(input())

def isPrime(n):
	for i in range(2, int(n ** 0.5) + 1):
		if n % i == 0:
			return False
	return True
for i in range(1, 1000):
	if not isPrime(num * i + 1):
		print(i)
		break


a = int(input())
if a == 1:
	print(3)
elif a == 2:
	print(4)
else:
	print(a - 2)


n = int(input())
if n % 2 == 1 and n != 1:
	print(1)
elif n != 1000:
	print(n + 2)
elif n == 1:
	print(5)
else:
	print(2)


n = int(input())

def isPrime(n):
	for i in range(2, int(n ** 0.5) + 1):
		if n % i == 0:
			return False
	return True
for i in range(1, 1000, 1):
	if isPrime(n * i + 1):
		continue
	else:
		print(i)
		exit()


from math import *

def func1(n):
	for i in range(2, ceil(sqrt(n)) + 1):
		if n % i == 0:
			return 1
	return 0
n = int(input())
for i in range(1, 1001):
	if (n * i + 1) % 2 == 0:
		if n * i + 1 != 2:
			print(i)
			exit(0)
	elif func1(n * i + 1) == 1:
		print(i)
		exit(0)


def prime(x):
	for i in range(2, 1001):
		if x % i == 0 and i != x:
			return False
	return True
n = int(input())
for m in range(1, 1001):
	if not prime(n * m + 1):
		print(m)
		exit()


a = int(input())
i = 1

def prime(n):
	if n == 2 or n == 3:
		return False
	if n % 2 == 0 or n % 3 == 0:
		return True
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return True
		i += 6
	return False
while i <= 1000:
	if prime(a * i + 1):
		print(i)
		break
	i += 1


import sys

def solve():
	n = int(input())
	if n == 1:
		ans = 3
	elif n == 2:
		ans = 4
	else:
		ans = n - 2
	print(ans)
solve()


primes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367]

def fact(n):
	for p in primes:
		if n % p == 0 and n > p:
			return True
		elif n == p:
			return False
	return False
n = int(input())
for i in range(1, 1000):
	if fact(n * i + 1):
		break
print(i)


n = int(input())
if n <= 2:
	print('32')
else:
	print(n - 2)


import math
n = int(input())

def isprime(p):
	for i in range(2, min(round(math.sqrt(p) + 1), p)):
		if p % i == 0:
			return False
	return True
for m in range(1, 1001):
	c = n * m + 1
	if not isprime(c):
		print(m)
		break


print((lambda x: 3 if x % 2 != 0 else x - 2 if x == 1000 else x + 2)(int(input())))


import itertools
from math import sqrt

def is_prime(val):
	if val <= 3:
		return True
	for i in range(2, val):
		if val % i == 0:
			return False
	return True

def main():
	n = int(input())
	for m in range(1, 10001):
		if not is_prime(n * m + 1):
			print(m)
			return
main()


def isPrime(n):
	if n % 2 == 0:
		return n == 2
	d = 3
	while d * d <= n and n % d != 0:
		d += 2
	return d * d > n
n = int(input())
m = 1
while isPrime(n * m + 1):
	m += 1
print(m)


from math import sqrt

def product_remainders(number):
	divisors = [str(1)]
	flag = True
	for i in range(2, round(sqrt(number)) + 1):
		if number % i == 0:
			flag = False
			divisors.append(str(i))
	return flag
n = int(input())
for m in range(10 ** 3 + 1):
	if not product_remainders(n * m + 1):
		print(m)
		break


import sys
n = int(input())
for m in range(1, 1001):
	for j in range(2, 1001):
		if j < n * m + 1 and (n * m + 1) % j == 0:
			print(m)
			sys.exit()


n = int(input())
for i in range(1, 1001):
	a = i * n + 1
	check = False
	for j in range(2, a):
		if a % j == 0:
			check = True
			break
	if check == True:
		print(i)
		break


n = int(input())
if n < 999:
	print(n + 2)
else:
	print(1)
exit(0)


s = [1 for i in range(10 ** 4 + 1)]
s[0] = 0
s[1] = 0
for i in range(2, 10 ** 4 + 1):
	if s[i] == 1:
		for j in range(i * i, 10 ** 4 + 1, i):
			s[j] = 0
n = int(input())
if n == 2:
	print(4)
elif s[n] == 1:
	print(1)
else:
	for i in range(2, 10000, 2):
		if s[n * i + 1] == 0:
			print(i)
			break


from math import sqrt
n = int(input())

def isPrime(num):
	if num == 2 or num == 3:
		return True
	if num % 2 == 0 or num < 2:
		return False
	for i in range(3, int(sqrt(num)) + 1, 2):
		if num % i == 0:
			return False
	return True
if n % 2 != 0 and n > 1:
	print(1)
else:
	m = 1
	while m <= 1000:
		if not isPrime(n * m + 1):
			print(m)
			break
		m += 1


import math
n = int(input())
for i in range(1, 1000):
	m = n * i + 1
	k = math.sqrt(m)
	j = 2
	for l in range(j, math.floor(k + 1)):
		if m % j == 0:
			break
		j = j + 1
	if j <= k:
		print(i)
		break


def simple(a):
	for i in range(2, round(a ** 1 / 2)):
		if a % i == 0:
			return 0
	return 1
a = int(input())
if a % 2 == 0 or a == 1:
	for i in range(1, 1001):
		if simple(i * a + 1) == 0:
			print(i)
			break
else:
	print(1)


n = int(input())
if n % 2:
	if n == 1:
		x = 3
		print(x)
	else:
		print(n % 2)
elif n == 1000:
	x = 5
	print(x)
else:
	print(n + 2)


def sieve(n):
	primes = [True] * (n + 2)
	for i in range(2, n):
		if primes[i]:
			for j in range(i + i, n + 1, i):
				primes[j] = False
	return [i for i in range(2, n + 1) if primes[i]]

def main():
	primes = set(sieve(1000000))
	n = int(input())
	for m in range(1, 1000):
		if n * m + 1 not in primes:
			print(m)
			break
main()


def check_composite(num):
	for i in range(2, num):
		if num % i == 0:
			return True
			break
	return False
n = int(input())
for i in range(1000):
	if check_composite(n * i + 1):
		print(i)
		break


from math import sqrt
from itertools import count, islice

def isPrime(n):
	if n < 2:
		return False
	for number in islice(count(2), int(sqrt(n) - 1)):
		if not n % number:
			return False
	return True
n = int(input())
for i in range(1, 1001):
	if not isPrime(n * i + 1):
		print(i)
		break
	else:
		continue


def primo(num):
	cont = 0
	for a in range(1, num + 1):
		if num % a == 0:
			cont += 1
	if cont == 2:
		return True
	return False

def contraprova(n):
	m = 1
	while True:
		if primo(n * m + 1):
			m += 1
		else:
			break
	return m
n = int(input())
print(contraprova(n))


import math
n = int(input())
if n % 2 != 0:
	print(3)
else:
	m = 0
	while True:
		m += 1
		i = 2
		k = n * m + 1
		while i <= math.sqrt(k) and k % i != 0:
			i = i + 1
		if k % i == 0:
			print(m)
			break


T_ON = 0
DEBUG_ON = 1
MOD = 998244353

def solve():
	n = read_int()
	m = n + 2
	if m > 1000:
		m = n - 2
	print(m)

def main():
	T = read_int() if T_ON else 1
	for i in range(T):
		solve()

def debug(*xargs):
	if DEBUG_ON:
		print(*xargs)
from collections import *
import math
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def read_int():
	return int(input())

def read_ints():
	return list(map(int, input().split()))

def print_nums(nums):
	print(' '.join(map(str, nums)))

def YES():
	print('YES')

def Yes():
	print('Yes')

def NO():
	print('NO')

def No():
	print('No')

def First():
	print('First')

def Second():
	print('Second')

def fib(n):
	(a, b) = (0, 1)
	for _ in range(n):
		(a, b) = (b, a + b)
	return a

def fib_ns(n):
	assert n >= 1
	f = [0 for _ in range(n + 1)]
	f[0] = 0
	f[1] = 1
	for i in range(2, n + 1):
		f[i] = f[i - 1] + f[i - 2]
	return f

def fib_to_n(n):
	f = []
	(a, b) = (0, 1)
	while a <= n:
		f.append(a)
		(a, b) = (b, a + b)
	return f

def gcd(a, b):
	if a == 0:
		return b
	return gcd(b % a, a)

def xgcd(a, b):
	(x0, x1, y0, y1) = (0, 1, 1, 0)
	while a != 0:
		((q, a), b) = (divmod(b, a), a)
		(y0, y1) = (y1, y0 - q * y1)
		(x0, x1) = (x1, x0 - q * x1)
	return (b, x0, y0)

def lcm(a, b):
	d = gcd(a, b)
	return a * b // d

def is_even(x):
	return x % 2 == 0

def is_odd(x):
	return x % 2 == 1

def modinv(a, m):
	(g, x, _) = xgcd(a, m)
	if g != 1:
		raise Exception('gcd(a, m) != 1')
	return x % m

def mod_add(x, y):
	x += y
	while x >= MOD:
		x -= MOD
	while x < 0:
		x += MOD
	return x

def mod_mul(x, y):
	return x * y % MOD

def mod_pow(x, y):
	if y == 0:
		return 1
	if y % 2:
		return mod_mul(x, mod_pow(x, y - 1))
	p = mod_pow(x, y // 2)
	return mod_mul(p, p)

def mod_inv(y):
	return mod_pow(y, MOD - 2)

def mod_div(x, y):
	return mod_mul(x, mod_inv(y))

def is_prime(n):
	if n == 1:
		return False
	for i in range(2, int(n ** 0.5) + 1):
		if n % i:
			return False
	return True

def gen_primes(n):
	P = [True for _ in range(n + 1)]
	P[0] = P[1] = False
	for i in range(int(n ** 0.5) + 1):
		if P[i]:
			for j in range(2 * i, n + 1, i):
				P[j] = False
	return P
main()


def ans(k):
	for i in range(2, k // 2 + 1, 1):
		if k % i == 0:
			return True
	return False
t = int(input())
f = 0
for i in range(1, 10000, 1):
	if ans(t * i + 1) == True:
		f = i
		break
print(f)


def prost(k):
	i = 2
	while i ** 2 <= k:
		if not k % i:
			return False
		i += 1
	return True
n = int(input())
m = 1
while prost(m * n + 1):
	m += 1
print(m)


n = int(input())
c = True
m = 1

def prime(x):
	t = []
	for i in range(x, 0, -1):
		if x % i == 0:
			t.append(i)
	if len(t) == 2:
		return True
	else:
		return False
while c != False:
	if prime(n * m + 1) == True:
		m = m + 1
	else:
		print(m)
		break


a = int(input())
if a == 1:
	print('8')
elif a == 2:
	print('4')
else:
	print('%d' % (a - 2))


x = int(input())
hasNumber = False
for i in range(1, 103):
	a = x * i + 1
	if hasNumber:
		break
	for j in range(2, a):
		if hasNumber:
			break
		elif a % j == 0:
			numberM = i
			hasNumber = True
print(numberM)


n = int(input())

def prime(n):
	if n == 2:
		return True
	elif n % 2 == 0:
		return False
	else:
		for i in range(3, int(pow(n, 0.5)) + 1, 2):
			if n % i == 0:
				return False
	return True
for i in range(1, 1000 + 1):
	if prime(n * i + 1) == False:
		flag = 1
		print(i)
		break


def prime(n):
	c = 0
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			c += 1
	if c > 1:
		return False
	return True
n = int(input())
m = 1
while m < 10:
	if prime(n * m + 1):
		m = m + 1
	else:
		print(m)
		break


n = int(input())
if n > 2:
	print(n - 2)
if n == 2:
	print(4)
if n == 1:
	print(3)


def ehPrimo(n):
	quant = 0
	for i in range(1, n + 1):
		if n % i == 0:
			quant += 1
	if quant == 2:
		return True
	else:
		return False
n = int(input())
achou = False
m = 1
while not achou:
	if ehPrimo(m * n + 1):
		m += 1
	else:
		achou = True
print(m)


m = 10 ** 4

def seive(n):
	primes = [1] * n
	primes[0] = primes[1] = 0
	for i in range(4, n, 2):
		if i % 2 == 0:
			primes[i] = 0
	for i in range(3, n, 2):
		for j in range(i + i, n, i):
			primes[j] = 0
	return primes
p = seive(m)
n = int(input())
for i in range(1, m):
	z = n * i + 1
	if p[z] == 0:
		print(i)
		break


import sys

def sieve(limit=1000000):
	yield 2
	sub_limit = int(limit ** 0.5)
	flags = [False, False] + [True] * (limit - 2)
	for i in range(3, limit, 2):
		if flags[i] is False:
			continue
		yield i
		if i <= sub_limit:
			for j in range(i * 3, limit, i << 1):
				flags[j] = False
n = int(input())
primes = sieve(9999)
x = 1
while n == n:
	if n * x + 1 in primes:
		x += 1
	else:
		break
print(x)


n = int(input())
import math
for m in range(1, 1000):
	s = n * m + 1
	f = 1
	while f <= math.sqrt(s):
		som = 0
		if s % f == 0:
			som = som + f
			c = som
		f = f + 1
	if c != 1:
		print(m)
		break


def isprime(n):
	if n == 1 or n == 2 or n == 3:
		return True
	if n > 3:
		for i in range(2, n // 2):
			if n % i == 0:
				return False
				break
		else:
			return True
n = int(input())
for i in range(1, 1001):
	a = n * i + 1
	if n == 3:
		print(1)
		break
	if isprime(a) == False:
		print(i)
		break


x = int(input())
arr = [0] * 10000
arr[0] = 1
arr[1] = 1
for i in range(2, 10000):
	if arr[i] == 0:
		for j in range(2 * i, 10000, i):
			arr[j] = 1
i = 1
while True:
	if arr[x * i + 1] == 1:
		print(i)
		break
	else:
		i += 1


def isprime(n):
	a = 0
	if n == 1:
		return 0
	for x in range(2, n):
		if n % x == 0:
			a = 1
	return a
n = int(input())
i = 0
while True:
	i += 1
	a = isprime(i * n + 1)
	if a == 1:
		break
print(i)


import math

def isPrime(n):
	for i in range(2, math.floor(math.sqrt(n)) + 1):
		if n % i == 0:
			return False
	return True
n = int(input())
if n == 1:
	print(3)
elif n % 2 == 1:
	print(1)
else:
	found = False
	i = 1
	if not isPrime(i * n + 1):
		found = True
	while not found:
		i += 1
		if not isPrime(i * n + 1):
			found = True
	print(i)


def isprime(n):
	flag = 0
	for i in range(2, int(n ** 0.5) + 1):
		if n % i == 0:
			flag = 1
	if flag == 1:
		return 0
	else:
		return 1
n = int(input())
m = 1
while True:
	if not isprime(m * n + 1):
		print(m)
		break
	m += 1


n = int(input())

def prime(num):
	count = 0
	for i in range(num):
		if num % (i + 1) == 0:
			count += 1
	if count == 2:
		return True
	else:
		return False
i = 1
while True:
	if prime(n * i + 1) == False:
		print(i)
		break
	else:
		i += 1


n = int(input())
m = 0
c = 0
op = 0
while True:
	m += 1
	c = n * m + 1
	op = 0
	for i in range(2, c):
		if c % i == 0:
			op = 1
			break
	if op == 1:
		break
print(m)


from math import *
n = int(input())
if n % 2:
	print(3)
elif n == 2:
	print(4)
else:
	print(n - 2)


def verify_primo(x):
	divisor = 2
	while divisor < x:
		if x % divisor == 0:
			return False
		divisor += 1
	return True
entrada = int(input())
result = 1
eh_primo = True
while True:
	eh_primo = verify_primo(entrada * result + 1)
	if eh_primo == False:
		print(result)
		break
	result += 1


import sys
from math import factorial

def isprime(x):
	return factorial(x - 1) % x == x - 1
n = int(input())
i = 10
if n & 1 == 1:
	print(3)
	sys.exit()
else:
	while i > 0:
		if isprime(n * i + 1):
			i -= 1
			continue
		else:
			print(i)
			sys.exit()


import math, fractions, collections

def isPrime(n):
	for i in range(2, int(math.sqrt(n)) + 1):
		if n % i == 0:
			return False
	return True
n = int(input())
m = 9
while isPrime(n * m + 1):
	m += 1
print(m)


n = int(input())
if n < 999:
	print(n + 2)
else:
	print(1)


from math import sqrt
from itertools import count, islice

def isPrime(n):
	return n > 1 and all((n % i for i in islice(count(2), int(sqrt(n) - 1))))
n = int(input())
for i in range(1, 1005):
	rez = n * i + 1
	if isPrime(rez) == False:
		print(i)
		break
	else:
		continue


def isPrime(n):
	for i in range(2, int(n ** 0.5) + 1):
		if n % i == 0:
			return False
	return True
n = int(input())
if n == 1:
	print(3)
elif n == 2:
	print(4)
elif n == 3:
	print(1)
elif n == 4:
	print(2)
elif n == 5:
	print(1)
elif n == 6:
	print(4)
else:
	m = 1
	while True:
		if not isPrime(n * m + 1):
			print(m)
			break
		m = m + 1


import math

def Prime(n):
	isPrime = True
	for i in range(2, int(math.sqrt(n) + 1)):
		if n % i == 0:
			isPrime = False
			break
	return isPrime
i = 1
n = int(input())
while True:
	num = n * i + 1
	if not Prime(num):
		print(i)
		break
	i += 1


f = int(input())
if f == 1:
	print(3)
elif f == 2:
	print(4)
else:
	print(f - 2)


cunt = 0
n = int(input())
if n % 2 != 0:
	if n == 1:
		print(3)
	else:
		print(1)
else:
	for i in range(1, 1001):
		if cunt == 1:
			break
		prime = n * i + 1
		for j in range(3, prime, 2):
			if prime % j == 0:
				print(i)
				cunt = 1
				break


def prime(no):
	n = no
	d = 2
	while d < n:
		if n % d == 0:
			return False
		d += 1
	return True
n = int(input())
m = 1
count = 0
while count != 1:
	no = n * m + 1
	ans = prime(no)
	if not ans:
		print(m)
		count = 1
		break
	else:
		m = m + 1


def eprimo(n):
	if n == 1:
		return False
	if n == 2 or n == 3:
		return True
	for a in range(2, int(n ** (1 / 2)) + 1):
		if n % a == 0:
			return False
	return True
n = int(input())
if eprimo(n):
	if n == 2:
		print(4)
	else:
		print(1)
else:
	for i in range(1, 1000):
		if not eprimo(n * i + 1):
			print(i)
			break


n = int(input())
if n < 10:
	print(n + 2)
else:
	print(n - 2)


def eratosthenes(n):
	sieve = list(range(n + 1))
	sieve[1] = 0
	prime = []
	for i in sieve:
		if i > 0:
			prime.append(i)
			for j in range(i * i, len(sieve), i):
				sieve[j] = 0
	return prime
n = int(input())
ans = 0
if n == 1:
	ans = 3
elif n % 2:
	ans = 1
else:
	p = eratosthenes(n * 1000)
	for i in range(1, 1001):
		if i * n + 1 not in p:
			ans = i
			break
print(ans)


n = int(input())
p = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41]
if n % 2 == 1:
	print(3)
else:
	m = 1
	i = 0
	while (n * m * 100 + 1) % p[i] != 0:
		if m == 10:
			m = 1
			i += 1
		else:
			m += 1
	print(m * 100)


num = int(input())
primos = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997, 1009, 1013, 1019, 1021, 1031, 1033, 1039, 1049, 1051, 1061, 1063, 1069, 1087, 1091, 1093, 1097, 1103, 1109, 1117, 1123, 1129, 1151, 1153, 1163, 1171, 1181, 1187, 1193, 1201, 1213, 1217, 1223, 1229, 1231, 1237, 1249, 1259, 1277, 1279, 1283, 1289, 1291, 1297, 1301, 1303, 1307, 1319, 1321, 1327, 1361, 1367, 1373, 1381, 1399, 1409, 1423, 1427, 1429, 1433, 1439, 1447, 1451, 1453, 1459, 1471, 1481, 1483, 1487, 1489, 1493, 1499, 1511, 1523, 1531, 1543, 1549, 1553, 1559, 1567, 1571, 1579, 1583, 1597, 1601, 1607, 1609, 1613, 1619, 1621, 1627, 1637, 1657, 1663, 1667, 1669, 1693, 1697, 1699, 1709, 1721, 1723, 1733, 1741, 1747, 1753, 1759, 1777, 1783, 1787, 1789, 1801, 1811, 1823, 1831, 1847, 1861, 1867, 1871, 1873, 1877, 1879, 1889, 1901, 1907, 1913, 1931, 1933, 1949, 1951, 1973, 1979, 1987, 1993, 1997, 1999, 2003, 2011, 2017, 2027, 2029, 2039, 2053, 2063, 2069, 2081, 2083, 2087, 2089, 2099, 2111, 2113, 2129, 2131, 2137, 2141, 2143, 2153, 2161, 2179, 2203, 2207, 2213, 2221, 2237, 2239, 2243, 2251, 2267, 2269, 2273, 2281, 2287, 2293, 2297, 2309, 2311, 2333, 2339, 2341, 2347, 2351, 2357, 2371, 2377, 2381, 2383, 2389, 2393, 2399, 2411, 2417, 2423, 2437, 2441, 2447, 2459, 2467, 2473, 2477, 2503, 2521, 2531, 2539, 2543, 2549, 2551, 2557, 2579, 2591, 2593, 2609, 2617, 2621, 2633, 2647, 2657, 2659, 2663, 2671, 2677, 2683, 2687, 2689, 2693, 2699, 2707, 2711, 2713, 2719, 2729, 2731, 2741, 2749, 2753, 2767, 2777, 2789, 2791, 2797, 2801, 2803, 2819, 2833, 2837, 2843, 2851, 2857, 2861, 2879, 2887, 2897, 2903, 2909, 2917, 2927, 2939, 2953, 2957, 2963, 2969, 2971, 2999, 3001, 3011, 3019, 3023, 3037, 3041, 3049, 3061, 3067, 3079, 3083, 3089, 3109, 3119, 3121, 3137, 3163, 3167, 3169, 3181, 3187, 3191, 3203, 3209, 3217, 3221, 3229, 3251, 3253, 3257, 3259, 3271, 3299, 3301, 3307, 3313, 3319, 3323, 3329, 3331, 3343, 3347, 3359, 3361, 3371, 3373, 3389, 3391, 3407, 3413, 3433, 3449, 3457, 3461, 3463, 3467, 3469, 3491, 3499, 3511, 3517, 3527, 3529, 3533, 3539, 3541, 3547, 3557, 3559, 3571, 3581, 3583, 3593, 3607, 3613, 3617, 3623, 3631, 3637, 3643, 3659, 3671, 3673, 3677, 3691, 3697, 3701, 3709, 3719, 3727, 3733, 3739, 3761, 3767, 3769, 3779, 3793, 3797, 3803, 3821, 3823, 3833, 3847, 3851, 3853, 3863, 3877, 3881, 3889, 3907, 3911, 3917, 3919, 3923, 3929, 3931, 3943, 3947, 3967, 3989, 4001, 4003, 4007, 4013, 4019, 4021, 4027, 4049, 4051, 4057, 4073, 4079, 4091, 4093, 4099, 4111, 4127, 4129, 4133, 4139, 4153, 4157, 4159, 4177, 4201, 4211, 4217, 4219, 4229, 4231, 4241, 4243, 4253, 4259, 4261, 4271, 4273, 4283, 4289, 4297, 4327, 4337, 4339, 4349, 4357, 4363, 4373, 4391, 4397, 4409, 4421, 4423, 4441, 4447, 4451, 4457, 4463, 4481, 4483, 4493, 4507, 4513, 4517, 4519, 4523, 4547, 4549, 4561, 4567, 4583, 4591, 4597, 4603, 4621, 4637, 4639, 4643, 4649, 4651, 4657, 4663, 4673, 4679, 4691, 4703, 4721, 4723, 4729, 4733, 4751, 4759, 4783, 4787, 4789, 4793, 4799, 4801, 4813, 4817, 4831, 4861, 4871, 4877, 4889, 4903, 4909, 4919, 4931, 4933, 4937, 4943, 4951, 4957, 4967, 4969, 4973, 4987, 4993, 4999, 5003, 5009, 5011, 5021, 5023, 5039, 5051, 5059, 5077, 5081, 5087, 5099, 5101, 5107, 5113, 5119, 5147, 5153, 5167, 5171, 5179, 5189, 5197, 5209, 5227, 5231, 5233, 5237, 5261, 5273, 5279, 5281, 5297, 5303, 5309, 5323, 5333, 5347, 5351, 5381, 5387, 5393, 5399, 5407, 5413, 5417, 5419, 5431, 5437, 5441, 5443, 5449, 5471, 5477, 5479, 5483, 5501, 5503, 5507, 5519, 5521, 5527, 5531, 5557, 5563, 5569, 5573, 5581, 5591, 5623, 5639, 5641, 5647, 5651, 5653, 5657, 5659, 5669, 5683, 5689, 5693, 5701, 5711, 5717, 5737, 5741, 5743, 5749, 5779, 5783, 5791, 5801, 5807, 5813, 5821, 5827, 5839, 5843, 5849, 5851, 5857, 5861, 5867, 5869, 5879, 5881, 5897, 5903, 5923, 5927, 5939, 5953, 5981, 5987, 6007, 6011, 6029, 6037, 6043, 6047, 6053, 6067, 6073, 6079, 6089, 6091, 6101, 6113, 6121, 6131, 6133, 6143, 6151, 6163, 6173, 6197, 6199, 6203, 6211, 6217, 6221, 6229, 6247, 6257, 6263, 6269, 6271, 6277, 6287, 6299, 6301, 6311, 6317, 6323, 6329, 6337, 6343, 6353, 6359, 6361, 6367, 6373, 6379, 6389, 6397, 6421, 6427, 6449, 6451, 6469, 6473, 6481, 6491, 6521, 6529, 6547, 6551, 6553, 6563, 6569, 6571, 6577, 6581, 6599, 6607, 6619, 6637, 6653, 6659, 6661, 6673, 6679, 6689, 6691, 6701, 6703, 6709, 6719, 6733, 6737, 6761, 6763, 6779, 6781, 6791, 6793, 6803, 6823, 6827, 6829, 6833, 6841, 6857, 6863, 6869, 6871, 6883, 6899, 6907, 6911, 6917, 6947, 6949, 6959, 6961, 6967, 6971, 6977, 6983, 6991, 6997, 7001, 7013, 7019, 7027, 7039, 7043, 7057, 7069, 7079, 7103, 7109, 7121, 7127, 7129, 7151, 7159, 7177, 7187, 7193, 7207, 7211, 7213, 7219, 7229, 7237, 7243, 7247, 7253, 7283, 7297, 7307, 7309, 7321, 7331, 7333, 7349, 7351, 7369, 7393, 7411, 7417, 7433, 7451, 7457, 7459, 7477, 7481, 7487, 7489, 7499, 7507, 7517, 7523, 7529, 7537, 7541, 7547, 7549, 7559, 7561, 7573, 7577, 7583, 7589, 7591, 7603, 7607, 7621, 7639, 7643, 7649, 7669, 7673, 7681, 7687, 7691, 7699, 7703, 7717, 7723, 7727, 7741, 7753, 7757, 7759, 7789, 7793, 7817, 7823, 7829, 7841, 7853, 7867, 7873, 7877, 7879, 7883, 7901, 7907, 7919, 7927, 7933, 7937, 7949, 7951, 7963, 7993, 8009, 8011, 8017, 8039, 8053, 8059, 8069, 8081, 8087, 8089, 8093, 8101, 8111, 8117, 8123, 8147, 8161, 8167, 8171, 8179, 8191, 8209, 8219, 8221, 8231, 8233, 8237, 8243, 8263, 8269, 8273, 8287, 8291, 8293, 8297, 8311, 8317, 8329, 8353, 8363, 8369, 8377, 8387, 8389, 8419, 8423, 8429, 8431, 8443, 8447, 8461, 8467, 8501, 8513, 8521, 8527, 8537, 8539, 8543, 8563, 8573, 8581, 8597, 8599, 8609, 8623, 8627, 8629, 8641, 8647, 8663, 8669, 8677, 8681, 8689, 8693, 8699, 8707, 8713, 8719, 8731, 8737, 8741, 8747, 8753, 8761, 8779, 8783, 8803, 8807, 8819, 8821, 8831, 8837, 8839, 8849, 8861, 8863, 8867, 8887, 8893, 8923, 8929, 8933, 8941, 8951, 8963, 8969, 8971, 8999, 9001, 9007, 9011, 9013, 9029, 9041, 9043, 9049, 9059, 9067, 9091, 9103, 9109, 9127, 9133, 9137, 9151, 9157, 9161, 9173, 9181, 9187, 9199, 9203, 9209, 9221, 9227, 9239, 9241, 9257, 9277, 9281, 9283, 9293, 9311, 9319, 9323, 9337, 9341, 9343, 9349, 9371, 9377, 9391, 9397, 9403, 9413, 9419, 9421, 9431, 9433, 9437, 9439, 9461, 9463, 9467, 9473, 9479, 9491, 9497, 9511, 9521, 9533, 9539, 9547, 9551, 9587, 9601, 9613, 9619, 9623, 9629, 9631, 9643, 9649, 9661, 9677, 9679, 9689, 9697, 9719, 9721, 9733, 9739, 9743, 9749, 9767, 9769, 9781, 9787, 9791, 9803, 9811, 9817, 9829, 9833, 9839, 9851, 9857, 9859, 9871, 9883, 9887, 9901, 9907, 9923, 9929, 9931, 9941, 9949, 9967, 9973]
contador = 1
while True:
	if contador * num + 1 not in primos:
		break
	else:
		contador += 1
print(contador)


sieve = [*range(1000002)]
p = 2
while p * p < 1000001:
	if sieve[p] != -1:
		for i in range(p + p, 1000002, p):
			sieve[i] = -1
	p += 1
x = []
for i in range(2, 1000002):
	if sieve[i] != -1:
		x.append(i)
n = int(input())
m = 1
k = 0
while True:
	if n * m + 1 not in x:
		k = 1
		break
	else:
		m += 1
if k == 1:
	print(m)


def aval(n):
	t = 0
	for i in range(2, int(n ** 0.5) + 1):
		if n % i == 0:
			return 1
	return 0
n = int(input())
t = 1
while aval(n * t + 1) == 0:
	t = t + 1
print(t)


import math

def isPrime(x):
	for y in range(2, int(math.sqrt(x)) + 1):
		if x % y == 0:
			return 0
	return 1

def main():
	n = int(input())
	for m in range(1, 1001):
		if not isPrime(n * m + 1):
			print(m)
			return
main()


prime = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29]

def find_m(n):
	m = -1
	i = 1
	while m == -1:
		a = n * i + 1
		for j in prime:
			if j != a and a % j == 0:
				m = i
		i = i + 1
	return m
n = int(input())
output = find_m(n)
print(output)


n = int(input())
i = 1
while i != 0:
	p = n * i + 1
	for u in range(p - 2):
		if p % (u + 2) == 0:
			print(i)
			exit()
	i += 1


from math import sqrt
n = int(input())

def check(n):
	for m in range(1, 1001):
		p = n * m + 1
		for i in range(2, int(sqrt(p)) + 1):
			if p % i == 0:
				return m
print(check(n))


n = int(input())
p = -1
ans = -1
flag = 0
for i in range(0, 1000):
	p = n * i + 1
	ans = i
	for j in range(2, int(p / 2) + 1):
		if p % j == 0:
			print(ans)
			exit()


from math import *
n = int(input())

def isPrime(n):
	if n == 1:
		return False
	if n == 2:
		return True
	for i in range(2, floor(sqrt(n))):
		if n % i == 0:
			return False
	return True
res = 0
for i in range(1, 1001):
	if not isPrime(n * i + 1):
		res = i
		break
print(res)


import math

def isPrime(n):
	if n == 2 or n == 3 or n == 5 or (n == 7):
		return True
	if n % 2 == 0:
		return False
	for k in range(3, math.ceil(math.sqrt(num)) + 1, 2):
		if n % k == 0:
			return False
			break
	return True
n = int(input())
for i in range(1, 1001):
	num = i * n + 1
	if isPrime(num):
		pass
	else:
		print(i)
		break


from itertools import count
n = int(input())
for d in (2, 3, 5, 7, 11, 13, 17, 19):
	if n % d != 0:
		for m in count(d):
			x = n * m + 1
			if x % d == 0:
				break
		print(m)
		break


def isPrime(k):
	for i in range(2, k):
		if k % i == 0:
			return False
	return True
n = int(input())
res = 1
while True:
	if not isPrime(n * res + 1):
		break
	res += 1
print(res)


from math import sqrt

def sieve(n):
	A = [True] * n
	for i in range(2, int(sqrt(n) + 1)):
		if A[i]:
			for j in range(i ** 2, n, i):
				A[j] = False
	return A

def solve():
	n = int(input())
	_sieve = sieve(n * 1001 + 1)
	for i in range(1, 1001):
		if not _sieve[n * i + 1]:
			return i
	return 2
print(solve())


def main():
	MAX = int(100000.0)
	is_prime = [True] * MAX
	primes = set([2, 3])
	for i in range(2, MAX // 2):
		is_prime[i * 2] = False
	for i in range(3, MAX):
		if is_prime[i]:
			primes.add(i)
			for j in range(i * i, MAX, i):
				is_prime[j] = False
	m = int(input())
	for n in range(1, int(1000.0)):
		if n * m + 1 not in primes:
			return n
	return -1
print(main())


def prime(x):
	i = 2
	while i * i <= x:
		if x % i == 0:
			return False
		i += 1
	return True
n = int(input())
if n == 1:
	print(3)
elif n % 2:
	print(1)
else:
	x = 2
	while x <= 100001:
		while (x - 1) % n:
			x += 1
		if prime(x) == False:
			print((x - 1) // n)
			break
		else:
			x += 1


def generarM(n):
	if n % 2 == 0 and n != 1000:
		return n + 2
	if n == 1000:
		return n - 2
	else:
		return 3
print(generarM(int(input())))


def isPrime(n):
	d = 2
	while n % d != 0 and d * d <= n:
		d += 1
	return d * d > n
n = int(input())
for m in range(1, 1001):
	a = n * m + 1
	if isPrime(a) == False:
		print(m)
		break


n = int(input())
if n == 1:
	print(3)
elif n % 2 == 1:
	print(1)
else:
	for m in range(1, 1001):
		p = n * m + 1
		ok = False
		for j in range(2, int(p ** 0.5) + 1):
			if p % j == 0:
				ok = True
				break
		if ok:
			print(m)
			break


l = int(input())
e = []
for i in range(1, 10):
	t = i * l + 1
	for x in range(2, t):
		if t % x == 0:
			e.append(i)
			break
print(min(e))


import sys
n = int(input())
if n == 1:
	print(3)
	sys.exit()
if n == 2:
	print(4)
	sys.exit()
else:
	print(n - 2)


import sys
import math
n = int(input())

def Prime(p):
	if p <= 3:
		return True
	if p % 2 == 0 or p % 3 == 0:
		return False
	for i in range(5, int(math.sqrt(p)), 6):
		if p % i == 0 or p % (i + 2) == 0:
			return False
	return True
for m in range(1, 1000):
	p = n * m + 1
	if not Prime(p):
		print(m)
		break


def isPrime(n):
	if n == 2:
		return True
	if n % 2 == 0:
		return False
	p = 3
	while p * p <= n:
		if n % p == 0:
			return False
		p += 2
	return True
n = int(input())
for m in range(1, 1000 + 1):
	if isPrime(n * m + 1) == False:
		print(m)
		break


n = int(input())

def is_prime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True
m = -1
for i in range(1, 10 ** 3):
	if not is_prime(n * i + 1):
		m = i
		break
print(m)


import random
import heapq
import math
from collections import Counter
import sys
from fractions import gcd
sys.setrecursionlimit(300000)
from random import randrange

def chinese_remainder(m, a):
	(res, prod) = (0, 1)
	for m_i in m:
		prod *= m_i
	for (m_i, a_i) in zip(m, a):
		p = prod // m_i
		res += a_i * modinv(p, m_i) * p
	return res % prod

def egcd(a, b):
	if a == 0:
		return (b, 0, 1)
	else:
		(g, y, x) = egcd(b % a, a)
		return (g, x - b // a * y, y)

def modinv(a, m):
	while a < 0:
		a += m
	(g, x, y) = egcd(a, m)
	if g != 1:
		raise Exception('Modular inverse does not exist')
	else:
		return x % m

def pi(n):
	lim = int(n ** 0.5)
	while lim * lim <= n:
		lim += 1
	lim -= 1
	(pi1, pi2) = ([0] * (lim + 1), [0] * (lim + 1))
	for i in range(1, lim + 1):
		pi1[i] = i - 1
		pi2[i] = n // i - 1
	for i in range(2, lim + 1):
		if pi1[i] == pi1[i - 1]:
			continue
		p = pi1[i - 1]
		for j in range(1, min(n // (i * i), lim) + 1):
			st = i * j
			if st <= lim:
				pi2[j] -= pi2[st] - p
			else:
				pi2[j] -= pi1[n // st] - p
		for j in range(lim, min(lim, i * i - 1), -1):
			pi1[j] -= pi1[j // i] - p
	return (pi1, pi2)

def num_of_divisors(n):
	nd = [0] * (n + 1)
	for i in range(1, n + 1):
		for j in range(i, n + 1, i):
			nd[j] += 1
	return nd

def sum_of_divisors(n):
	sd = [0] * (n + 1)
	for i in range(1, n + 1):
		for j in range(i, n + 1, i):
			sd[j] += i
	return sd

def fast_prime_sieve(n):
	n += 1
	(n, correction) = (n - n % 6 + 6, 2 - (n % 6 > 1))
	sieve = [True] * (n // 3)
	for i in range(1, int(n ** 0.5) // 3 + 1):
		if sieve[i]:
			k = 3 * i + 1 | 1
			sieve[k * k // 3::2 * k] = [False] * ((n // 6 - k * k // 6 - 1) // k + 1)
			sieve[k * (k - 2 * (i & 1) + 4) // 3::2 * k] = [False] * ((n // 6 - k * (k - 2 * (i & 1) + 4) // 6 - 1) // k + 1)
	return [2, 3] + [3 * i + 1 | 1 for i in range(1, n // 3 - correction) if sieve[i]]

def egcd(a, b):
	if a == 0:
		return (b, 0, 1)
	else:
		(g, y, x) = egcd(b % a, a)
		return (g, x - b // a * y, y)
_gcd = lambda a, b: a + b if a == 0 or b == 0 else gcd(b, a % b)

def gcd(a, b):
	if a == 0 or b == 0:
		return a + b
	return gcd(b, a % b)

def legendre_symbol(a, p):
	ls = pow(a, (p - 1) // 2, p)
	return -1 if ls == p - 1 else ls

def modular_sqrt(a, p):
	if legendre_symbol(a, p) != 1:
		return 0
	elif a == 0:
		return 0
	elif p == 2:
		return 0
	elif p % 4 == 3:
		return pow(a, (p + 1) // 4, p)
	s = p - 1
	e = 0
	while s % 2 == 0:
		s //= 2
		e += 1
	n = 2
	while legendre_symbol(n, p) != -1:
		n += 1
	x = pow(a, (s + 1) // 2, p)
	b = pow(a, s, p)
	g = pow(n, s, p)
	r = e
	while True:
		t = b
		m = 0
		for m in range(r):
			if t == 1:
				break
			t = pow(t, 2, p)
		if m == 0:
			return x
		gs = pow(g, 2 ** (r - m - 1), p)
		g = gs * gs % p
		x = x * gs % p
		b = b * g % p
		r = m
from functools import lru_cache

def factorize(n):
	factorization = set()
	while n > 1:
		for i in range(2, n + 1):
			if n % i == 0:
				n //= i
				factorization.add(i)
				break
	return factorization

@lru_cache(maxsize=None)
def phi(n):
	totient = n
	for p in factorize(n):
		totient -= totient // p
	return totient

def max_subarray(a):
	max_so_far = max_ending_here = 0
	for el in a:
		max_ending_here = max(0, max_ending_here + el)
		max_so_far = max(max_so_far, max_ending_here)
	return max_so_far

def maximum_xor(nums):
	answer = 0
	for i in range(31, -1, -1):
		answer <<= 1
		prefixes = {num >> i for num in nums}
		answer += any((answer ^ 1 ^ p in prefixes for p in prefixes))
	return answer

def lis(a):
	(p, m, l) = ([0] * len(a), [0] * (len(a) + 1), 0)
	for i in range(len(a)):
		(lo, hi) = (1, l)
		while lo <= hi:
			mid = (lo + hi) // 2
			if a[m[mid]] < a[i]:
				lo = mid + 1
			else:
				hi = mid - 1
		(p[i], m[lo]) = (m[lo - 1], i)
		if lo > l:
			l = lo
	(s, k) = ([], m[l])
	for i in range(l - 1, -1, -1):
		s.append(a[k])
		k = p[k]
	return s[::-1]

def find_kth(arr, k, start=0, end=None):
	if not end:
		end = len(arr) - 1
	pivot_ridx = randrange(start, end)
	pivot = arr[pivot_ridx]
	pivot_idx = _partition(arr, start, end, pivot_ridx)
	if pivot_idx + 1 == k:
		return pivot
	elif pivot_idx + 1 > k:
		return find_kth(arr, k, start, pivot_idx)
	else:
		return find_kth(arr, k, pivot_idx, end)

def _partition(arr, start, end, pivot_idx):
	pivot = arr[pivot_idx]
	(arr[end], arr[pivot_idx]) = (arr[pivot_idx], arr[end])
	inc_idx = start
	for i in range(start, end):
		if arr[i] <= pivot:
			(arr[inc_idx], arr[i]) = (arr[i], arr[inc_idx])
			inc_idx += 1
	(arr[end], arr[inc_idx]) = (arr[inc_idx], arr[end])
	return inc_idx

def count_sort(a):
	(mn, mx) = (float('inf'), -float('inf'))
	for x in a:
		if x < mn:
			mn = x
		if x > mx:
			mx = x
	counter = [0 for _ in range(mx - mn + 1)]
	for x in a:
		counter[x - mn] += 1
	j = 0
	for i in range(mx - mn + 1):
		a[j:j + counter[i]] = [i + mn] * counter[i]
		j += counter[i]

def lcs(a, b):
	lengths = [[0 for j in range(len(b) + 1)] for i in range(len(a) + 1)]
	for (i, x) in enumerate(a):
		for (j, y) in enumerate(b):
			if x == y:
				lengths[i + 1][j + 1] = lengths[i][j] + 1
			else:
				lengths[i + 1][j + 1] = max(lengths[i + 1][j], lengths[i][j + 1])
	result = []
	(x, y) = (len(a), len(b))
	while x != 0 and y != 0:
		if lengths[x][y] == lengths[x - 1][y]:
			x -= 1
		elif lengths[x][y] == lengths[x][y - 1]:
			y -= 1
		else:
			result.append(a[x - 1])
			(x, y) = (x - 1, y - 1)
	return result[::-1]

def is_anagram(str1, str2):
	return Counter(str1) == Counter(str2)

def power(x, y, p):
	res = 1
	x = x % p
	while y > 0:
		if y & 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def miillerTest(d, n):
	a = 2 + random.randint(1, n - 4)
	x = power(a, d, n)
	if x == 1 or x == n - 1:
		return True
	while d != n - 1:
		x = x * x % n
		d *= 2
		if x == 1:
			return False
		if x == n - 1:
			return True
	return False

def isPrime(n, k):
	if n <= 1 or n == 4:
		return False
	if n <= 3:
		return True
	d = n - 1
	while d % 2 == 0:
		d //= 2
	for i in range(k):
		if miillerTest(d, n) == False:
			return False
	return True

def gcd_list(li):
	return reduce(gcd, li)

def lis(a):
	(p, m, l) = ([0] * len(a), [0] * (len(a) + 1), 0)
	for i in range(len(a)):
		(lo, hi) = (1, l)
		while lo <= hi:
			mid = (lo + hi) // 2
			if a[m[mid]] < a[i]:
				lo = mid + 1
			else:
				hi = mid - 1
		(p[i], m[lo]) = (m[lo - 1], i)
		if lo > l:
			l = lo
	(s, k) = ([], m[l])
	for i in range(l - 1, -1, -1):
		s.append(a[k])
		k = p[k]
	return s[::-1]

def Base_n_to_10(X, n):
	out = 0
	for i in range(1, len(str(X)) + 1):
		out += int(X[-i]) * n ** (i - 1)
	return out
import math
n = int(input())
for i in range(1, 1001):
	if isPrime(n * i + 1, 4) == 0:
		print(i)
		break


t = [False for i in range(100000)]
prime = []
for i in range(2, 100000):
	if t[i] is False:
		prime.append(i)
		for j in range(i, 100000, i):
			t[j] = True
t = int(input())
j = 1
while True:
	m = t * j + 1
	j = j + 1
	if prime.count(m):
		continue
	else:
		break
print(j - 1)


def IsPrime(n):
	d = 2
	while n % d != 0:
		d += 1
	return d == n
n = int(input())
m = 1
while True:
	if not IsPrime(m * n + 1):
		print(m)
		exit(code=None)
	else:
		m += 1


def is_prime(x):
	i = 2
	while i * i <= x:
		if x % i == 0:
			return False
		else:
			i += 1
	return True
n = int(input())
if n == 1:
	print(120)
elif n % 2 == 1:
	print(1)
else:
	m = 1
	while is_prime(n * m + 1):
		m += 1
	print(m)


def isPrime(a):
	for i in range(2, a):
		if a % i == 0:
			return False
	return True
X = int(input())
if X % 2 != 0:
	print(1 if X != 1 else 3)
	exit()
for i in range(1, 10):
	Prime = X * i + 1
	if isPrime(Prime) == False:
		print(i)
		exit()


def isPrime(number):
	if number == 1:
		return False
	elif number == 2:
		return True
	for m in range(2, number, 1):
		if number % m == 0:
			return False
	return True

def returningM(number):
	m = 1
	while isPrime(number * m + 1):
		m += 1
	return m
inPut = int(input())
print(returningM(inPut))


n = int(input())
if n >= 3:
	print(str(n - 2))
else:
	print('7')


n = 1000001
isPrime = [True for i in range(n)]
isPrime[1] = False
isPrime[0] = False
i = 2
while i * i < n:
	if isPrime[i]:
		j = 2 * i
		while j < n:
			isPrime[j] = False
			j += i
	i += 1
m = int(input())
for i in range(1, 1001):
	if not isPrime[i * m + 1]:
		print(i)
		break


n = int(input())

def isprime(k):
	for i in range(2, k):
		if k % i == 0:
			return False
	return True
i = 1
while True:
	k = i * n + 1
	if isprime(k) == False:
		print(i)
		break
	i = i + 1


n = int(input())
if n % 2 != 0:
	if n == 1:
		print(3)
	else:
		print(1)
else:
	c = 0
	for i in range(1, 6):
		a = n * i + 1
		for j in range(2, a):
			if a % j == 0:
				c = 1
				break
		if c == 1:
			print(i)
			break


def isPrime(k, s=[2, 3, 5, 7, 11]):
	if k in s:
		return True
	return all((pow(k, x - 1, x) == 1 for x in s))
n = int(input())
for m in range(1, 1000 + 1):
	if not isPrime(n * m + 1):
		print(m)
		break


import math
n = int(input())

def is_composite(n):
	if n == 2:
		return False
	if n == 3:
		return False
	else:
		for i in range(2, int(math.sqrt(n)) + 1):
			if n % i == 0:
				return True
	return False

def f(n):
	m = 1
	while m >= 1:
		if is_composite(n * m + 1):
			return m
		m += 1
print(f(n))


def prost(g):
	for i in range(2, int(g ** 0.5) + 1):
		if g % i == 0:
			return False
	return True
n = int(input())
if n % 2 == 1:
	print(3)
else:
	i = 1
	while prost(n * i + 1):
		i += 1
	print(i)


n = int(input())
for i in range(1000):
	fl = 0
	num = i * n + 1
	for j in range(2, int(num * 0.5) + 1):
		if num % j == 0:
			fl = 1
			break
	if fl:
		break
print(i)


def call(x):
	for i in range(2, int(x ** 0.5) + 1):
		if x % i == 0:
			return 1
	return -1
n = int(input())
for i in range(1, n + 10):
	f = call(n * i + 1)
	if f == 1:
		print(i)
		break


def primo(n):
	for i in range(2, n):
		if n % i == 0:
			return False
	return True
n = int(input())
c = 1
numero = n * c + 1
while primo(numero) == True:
	c = c + 1
	numero = n * c + 1
print(c)


n = int(input())
if n % 2 == 1 and n != 1:
	print(n)
elif n == 1:
	print(3)
else:
	m = 1
	while (n * m + 1) ** 0.5 != int((n * m + 1) ** 0.5):
		m += 1
	print(m)


n = int(input())
import math
for i in range(1, 10 * 10 * 10):
	k = n * i + 1

	def is_prime(k):
		if k < 2:
			return False
		if k == 2:
			return True
		if k % 2 == 0:
			return False
		prime = True
		j = int(math.sqrt(k) + 1)
		for p in range(3, j, 2):
			if k % p == 0:
				return False
		return True
	goon = is_prime(k)
	if not goon:
		print(i)
		break


n = int(input())
if n % 2 == 1:
	print(3)
else:

	def prost(n):
		s = 0
		for i in range(n):
			if n % (i + 1) == 0:
				s = s + 1
		if s == 2:
			return True
		else:
			return False
	f = True
	m = 1
	while f:
		if not prost(n * m + 1):
			print(m)
			f = False
		m = m + 1


import math, sys

def primo(n):
	for a in range(2, int(math.sqrt(n) + 1)):
		if n % a == 0:
			return False
	return True
n = int(input())
m = 1
while True:
	if primo(n * m + 1) == False:
		print(m)
		sys.exit(0)
	m += 1


def check_prime(a):
	k = 2
	while k * k <= a:
		if a % k == 0:
			return True
		k += 1
	return False
n = int(input())
for i in range(1, 1001):
	if check_prime(n * i + 1):
		print(i)
		exit(0)


def not_pr(x):
	return sum((x % i == 0 for i in range(2, x))) != 0
read = lambda : map(int, input().split())
n = int(input())
for m in range(1, 1001):
	if not_pr(n * m + 1):
		print(m)
		return


import math

def is_prime(n):
	if n % 2 == 0 and n > 2:
		return False
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		if n % i == 0:
			return False
	return True
x = int(input())
c = 1
while is_prime(x * c + 1):
	c += 1
print(c)


n = int(input())
m = 1
p = 0
if n % 2 != 0 and n > 1:
	print(n)
elif n % 2 != 0 and n == 1:
	print(3)
elif n == 2:
	print(4)
elif n % 2 == 0 and n > 2:
	if n * (n - 2) + 1 == (n - 1) * (n - 1):
		print(n - 2)


import sys
import os
import math
import copy
from math import gcd
from bisect import bisect
from io import BytesIO, IOBase
from math import sqrt, floor, factorial, gcd, log, ceil
from collections import deque, Counter, defaultdict
from itertools import permutations, combinations
import itertools

def Int():
	return int(sys.stdin.readline())

def Mint():
	return map(int, sys.stdin.readline().split())

def Lstr():
	return list(sys.stdin.readline().strip())

def Str():
	return sys.stdin.readline().strip()

def Mstr():
	return map(str, sys.stdin.readline().strip().split())

def List():
	return list(map(int, sys.stdin.readline().split()))

def Hash():
	return dict()

def Mod():
	return 1000000007

def Ncr(n, r, p):
	return fact[n] * (ifact[r] * ifact[n - r] % p) % p

def Most_frequent(list):
	return max(set(list), key=list.count)

def Mat2x2(n):
	return [List() for _ in range(n)]

def Lcm(x, y):
	return x * y // gcd(x, y)

def dtob(n):
	return bin(n).replace('0b', '')

def btod(n):
	return int(n, 2)

def solution():
	n = Int()
	if n > 2:
		print(n - 2)
	else:
		print(n + 2)
solution()


def pla(n):
	i = 2
	while i * i < n:
		if not n % i:
			return True
		else:
			i += 1
	return False
n = int(input())
if n == 1:
	print(3)
elif n == 2:
	print(4)
else:
	for m in range(1, 1000):
		if pla(m * n + 1):
			print(m)
			break


(data, valor) = (int(input()), 1)

def not_prime(x):
	for check in range(2, int(x ** 0.5) + 1):
		if x % check == 0:
			return True
	return False
while True:
	if not_prime(data * valor + 1):
		print(valor)
		break
	valor += 1


n = int(input())
if n % 2 != 0:
	print(3)
else:
	b = 0
	for i in range(1, 1001):
		temp = n * i + 1
		for j in range(2, temp):
			if temp % j == 0:
				print(i)
				b = 1
				break
		if b == 1:
			break


x = int(input())
for i in range(1, 20):
	for j in range(2, (x * i + 1) // 2 + 1):
		if (x * i + 1) % j == 0:
			print(i)
			exit()


n = int(input())
k = 1000
i = 1

def is_prime(n):
	return all([n % j for j in range(2, int(n ** 0.5) + 1)]) and n > 1
while i < k:
	ans = n * i + 1
	if is_prime(ans) == False:
		print(i)
		exit(0)
	i += 1


def isprime(p):
	if p < 2:
		return False
	else:
		for scan in range(2, p):
			if p % scan == 0:
				return False
	return True
n = int(input())
for i in range(1, 1001):
	if not isprime(n * i + 1):
		print(i)
		break


import sys
import math

def is_prime(k):
	p = 2
	root_k = math.sqrt(k)
	for p in range(2, math.ceil(root_k) + 1):
		if k % p == 0:
			return False
	return True
n = int(input())
if n % 2 == 1:
	m = 3
else:
	m = 1
	while m <= 1000:
		if not is_prime(n * m + 1):
			break
		m += 1
print(m)


n = int(input())
if n % 2 == 1 and n != 1:
	print(n)
elif n == 1:
	print(3)
elif n == 2:
	print(4)
elif n == 6:
	print(4)
elif n == 210:
	print(4)
elif n == 330:
	print(5)
elif n == 18:
	print(3)
elif n == 24:
	print(1)
else:
	s = n % 3
	if s == 0:
		print(4)
	else:
		print(n // 2)


inp = int(input())
if inp == 2:
	print(7)
if inp > 2:
	print(inp - 2)
if inp == 1:
	print(7)


import math
n = int(input())
if n <= 2:
	print(7)
else:
	print(n - 2)


def prime(n):
	i = 2
	while i * i <= n:
		if n % i == 0:
			return False
		i += 1
	return True

def main(n):
	m = 1
	while True:
		if not prime(m * n + 1):
			print(m)
			return
		m += 1
main(int(input()))


import math
n = int(input())
for i in range(1, 1001):
	p = n * i + 1
	if p == 5 or p == 7 or p == 3 or (p == 2):
		pass
	elif p % 2 == 0 or p % 3 == 0 or p % 5 == 0 or (p % 7 == 0):
		print(i)
		break
	elif math.sqrt(p) == int(math.sqrt(p)):
		print(i)
		break


import unittest
import sys

class Primes:

	def __init__(self, maxn=10 ** 5):
		self.pfs = [0] * (maxn + 1)
		self.primes = []
		for i in range(2, maxn + 1):
			if self.pfs[i] == 0:
				self.pfs[i] = i
				self.primes.append(i)
				s = i * i
				if s <= maxn:
					for j in range(s, maxn + 1, i):
						self.pfs[j] = i

	def pf(self, n):
		return self.pfs[n]

	def is_prime(self, n):
		return n > 1 and self.pf(n) == n

class Hypo:

	def __init__(self, test_inputs=None):
		it = iter(test_inputs.split('\n')) if test_inputs else None

		def uinput():
			return next(it) if it else sys.stdin.readline().rstrip()
		[self.n] = map(int, uinput().split())
		self.prm = Primes()

	def is_prime(self, p):
		return self.prm.is_prime(p)

	def calculate(self):
		result = 0
		for m in range(1, 1001):
			if not self.is_prime(self.n * m + 1):
				result = m
				break
		return str(result)

class unitTests(unittest.TestCase):

	def test_single_test(self):
		test = '3'
		d = Hypo(test)
		self.assertEqual(d.n, 3)
		d = Hypo(test)
		self.assertEqual(d.is_prime(1), 0)
		self.assertEqual(d.is_prime(2), 1)
		self.assertEqual(d.is_prime(3), 1)
		self.assertEqual(d.is_prime(4), 0)
		self.assertEqual(d.is_prime(6), 0)
		self.assertEqual(Hypo(test).calculate(), '1')
		test = '4'
		self.assertEqual(Hypo(test).calculate(), '2')
		test = '1000'
		self.assertEqual(Hypo(test).calculate(), '0')
		test = ''

	def time_limit_test(self, nmax):
		import random
		import timeit
		test = str(nmax) + ' ' + str(nmax) + '\n'
		numnums = [str(i) + ' ' + str(i + 1) for i in range(nmax)]
		test += '\n'.join(numnums) + '\n'
		nums = [random.randint(1, 10000) for i in range(nmax)]
		test += ' '.join(map(str, nums)) + '\n'
		start = timeit.default_timer()
		d = Hypo(test)
		calc = timeit.default_timer()
		d.calculate()
		stop = timeit.default_timer()
		print('\nTimelimit Test: ' + '{0:.3f}s (init {1:.3f}s calc {2:.3f}s)'.format(stop - start, calc - start, stop - calc))
sys.setrecursionlimit(100000)
if sys.argv[-1] == '-ut':
	unittest.main(argv=[' '])
sys.stdout.write(Hypo().calculate())


is_prime = lambda n: all((n % d for d in range(2, int(n ** 0.5) + 1)))
(n, m) = (int(input()), 1)
while is_prime(n * m + 1):
	m += 1
print(m)


import math
import sys

def isPrime(n):
	if n % 2 == 0:
		return n == 2
	d = 3
	while d * d <= n and n % d != 0:
		d += 2
	return d * d > n
n = int(input())
m = 1
while True:
	a = n * m + 1
	if not isPrime(a):
		print(m)
		sys.exit()
	m += 1


from math import ceil, sqrt

def isPrime(x):
	if x == 2:
		return True
	for i in range(2, ceil(sqrt(x)) + 1):
		if x % i == 0:
			return False
	return True
n = int(input())
i = 1
while isPrime(n * i + 1):
	i += 1
print(i)


def main():
	n = int(input())
	if n & 1:
		print('31'[n > 1])
		return
	for m in range(1, 6):
		x = n * m + 1
		for p in (3, 5, 7, 11, 13, 17, 19, 29, 31):
			if p < x and (not x % p):
				print(m)
				return
main()


n = int(input())

def yes(x):
	if x < 3:
		return 0
	else:
		for y in range(2, x):
			if x % y == 0:
				return 1
		return 0
for m in range(1, 1001):
	if yes(n * m + 1):
		print(m)
		break


print([0, 3, 4, 1, 2, 1, 4, 1, 1, 1, 2, 1, 2, 1, 1, 1, 2, 1, 3, 1, 1, 1, 2, 1, 1, 1, 1, 1, 2, 1, 3, 1, 1, 1, 1, 1, 4, 1, 1, 1, 2, 1, 2, 1, 1, 1, 2, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 2, 1, 2, 1, 1, 1, 1, 1, 2, 1, 1, 1, 2, 1, 2, 1, 1, 1, 1, 1, 3, 1, 1, 1, 2, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, 2, 1, 2, 1, 1, 1, 2, 1, 2, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1, 1, 1, 2, 1, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 2, 1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 2, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 2, 1, 1, 1, 2, 1, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 2, 1, 3, 1, 1, 1, 2, 1, 1, 1, 1, 1, 2, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 2, 1, 4, 1, 1, 1, 1, 1, 2, 1, 1, 1, 2, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 4, 1, 1, 1, 2, 1, 2, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 5, 1, 1, 1, 1, 1, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 2, 1, 1, 1, 2, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 3, 1, 1, 1, 2, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 2, 1, 1, 1, 1, 1, 3, 1, 1, 1, 2, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 2, 1, 2, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, 2, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 2, 1, 2, 1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 2, 1, 4, 1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 2, 1, 1, 1, 2, 1, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 2, 1, 1, 1, 2, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 2, 1, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 4, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 2, 1, 1, 1, 2, 1, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 2, 1, 2, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, 2, 1, 2, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, 2, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, 2, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 3, 1, 1, 1, 1][int(input())])


n = int(input())

def isPrime(n):
	i = 2
	while i * i <= n:
		if n % i == 0:
			return False
		i += 1
	return True
for i in range(1, 1000):
	if not isPrime(n * i + 1):
		print(i)
		exit()


def ez(x):
	p = 1
	if x < 2:
		p = 0
	for i in range(2, x):
		if x % i is 0:
			p = 0
	return p
n = int(input())
i = 1
while True:
	if ez(n * i + 1) is 0:
		break
	i += 1
print(i)


import math
n = int(input())
m = 1
otv = 0
x = 2
if (n * m + 1) % 2 == 0:
	otv = 1
if n == 1:
	otv = 3
if otv != 1:
	while otv == 0:
		while x <= math.ceil(math.sqrt(m * n + 1)):
			if (m * n + 1) % x == 0:
				otv = m
				exit
			x = x + 1
		m = m + 1
		x = 2
print(otv)


n = int(input())
m = 1000
for i in range(1, m):
	k = n * i + 1
	if k != 2 and k != 3 and (k != 5) and (k != 7) and (k != 11) and (k != 13):
		if k % 2 == 0 or k % 3 == 0 or k % 5 == 0 or (k % 7 == 0) or (k % 11 == 0):
			print(i)
			break


def sieve(n):
	ans = []
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	for p in range(2, n):
		if prime[p]:
			ans.append(p)
	return ans
ans = sieve(10 ** 6 + 1)
n = int(input())
f = 0
for i in range(1, 10 ** 3 + 1):
	m = i
	if n * m + 1 in ans:
		pass
	else:
		print(m)
		break


def get_prime(n):
	value = True
	for i in range(2, n):
		if n % i == 0:
			value = False
	return value
n = int(input())
m = 1
check = n * m + 1
while get_prime(check):
	m = m + 1
	check = n * m + 1
print(m)


no = int(input())
ans = 0
for i in range(1, 100):
	ans = no * i + 1
	for j in range(2, (no * i + 1) // 2 + 1):
		if ans % j == 0:
			print(i)
			exit()


n = int(input())
if n < 990:
	print(n + 2)
else:
	print(n - 2)


def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 2
	return True
n = int(input())
for i in range(1, 1001):
	if not isPrime(n * i + 1):
		print(i)
		exit()


def is_prime(x):
	if x == 2:
		return True
	elif x == 1:
		return False
	if x % 2 == 0:
		return False
	c = 3
	while c * c <= x + 1:
		if x % c == 0:
			return False
		c += 2
	return True
n = int(input())
for i in range(1, 1001):
	if not is_prime(n * i + 1):
		print(i)
		break


n = int(input())
for m in range(1, 1000):
	k = n * m + 1
	t = 0
	for i in range(2, int(k ** 0.5) + 1):
		if k % i == 0:
			t = t + 1
			break
	if t != 0:
		print(m)
		break


def primo(n, div=2):
	if n == 0:
		return False
	elif n == 1:
		return False
	elif div * div > n:
		return True
	elif n % div == 0:
		return False
	else:
		return primo(n, div + 1)
n = int(input())
m = 1
while True:
	if primo(n * m + 1):
		m += 1
	else:
		break
print(m)


n = int(input())
if n % 2 == 1 and n != 1:
	print(1)
elif n == 1:
	print(3)
else:
	primes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101]
	m = 2
	found = False
	while not found:
		if m * n + 1 <= 101:
			for p in primes:
				if p == m * n + 1:
					m += 1
					break
				elif p > m * n + 1:
					found = True
					break
		else:
			for p in primes:
				if (m * n + 1) % p == 0:
					found = True
					break
			else:
				m += 1
	print(m)


def is_prime(num: int) -> bool:
	if num == 0 or num == 1:
		return False
	i = 2
	while i * i <= num:
		if num % i == 0:
			return False
		i += 1
	return True
n = int(input())
for m in range(1, 10 ** 3):
	if is_prime(n * m + 1):
		continue
	else:
		print(m)
		break


n = int(input())
prost = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409]
m = 1
f = 0
while f == 0:
	i = 0
	while prost[i] <= (m * n + 1) ** 0.5:
		if (m * n + 1) % prost[i] == 0:
			f = 1
		i += 1
	m += 1
print(m - 1)


def isPrime(num):
	for i in range(2, num // 2 + 1):
		if num % i == 0:
			return False
	return True
n = int(input())
for i in range(1, 10 ** 3 + 1):
	if not isPrime(i * n + 1):
		print(i)
		break


import sys
n = int(input())
l = (2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997, 1009, 1013, 1019, 1021, 1031, 1033, 1039, 1049, 1051, 1061, 1063, 1069, 1087, 1091, 1093, 1097, 1103, 1109, 1117, 1123, 1129, 1151, 1153, 1163, 1171, 1181, 1187, 1193, 1201, 1213, 1217, 1223, 1229, 1231, 1237, 1249, 1259, 1277, 1279, 1283, 1289, 1291, 1297, 1301, 1303, 1307, 1319, 1321, 1327, 1361, 1367, 1373, 1381, 1399, 1409, 1423, 1427, 1429, 1433, 1439, 1447, 1451, 1453, 1459, 1471, 1481, 1483, 1487, 1489, 1493, 1499, 1511, 1523, 1531, 1543, 1549, 1553, 1559, 1567, 1571, 1579, 1583, 1597, 1601, 1607, 1609, 1613, 1619, 1621, 1627, 1637, 1657, 1663, 1667, 1669, 1693, 1697, 1699, 1709, 1721, 1723, 1733, 1741, 1747, 1753, 1759, 1777, 1783, 1787, 1789, 1801, 1811, 1823, 1831, 1847, 1861, 1867, 1871, 1873, 1877, 1879, 1889, 1901, 1907, 1913, 1931, 1933, 1949, 1951, 1973, 1979, 1987, 1993, 1997, 1999, 2003, 2011, 2017, 2027, 2029, 2039, 2053, 2063, 2069, 2081, 2083, 2087, 2089, 2099, 2111, 2113, 2129, 2131, 2137, 2141, 2143, 2153, 2161, 2179, 2203, 2207, 2213, 2221, 2237, 2239, 2243, 2251, 2267, 2269, 2273, 2281, 2287, 2293, 2297, 2309, 2311, 2333, 2339, 2341, 2347, 2351, 2357, 2371, 2377, 2381, 2383, 2389, 2393, 2399, 2411, 2417, 2423, 2437, 2441, 2447, 2459, 2467, 2473, 2477, 2503, 2521, 2531, 2539, 2543, 2549, 2551, 2557, 2579, 2591, 2593, 2609, 2617, 2621, 2633, 2647, 2657, 2659, 2663, 2671, 2677, 2683, 2687, 2689, 2693, 2699, 2707, 2711, 2713, 2719, 2729, 2731, 2741, 2749, 2753, 2767, 2777, 2789, 2791, 2797, 2801, 2803, 2819, 2833, 2837, 2843, 2851, 2857, 2861, 2879, 2887, 2897, 2903, 2909, 2917, 2927, 2939, 2953, 2957, 2963, 2969, 2971, 2999)
if n % 2 != 0:
	print(1) if n != 1 else print(3)
else:
	f = 2
	while f <= 3000:
		m = f * n + 1
		if m not in l:
			print(f)
			sys.exit()
		else:
			f += 2


n = int(input())
c = 0
for i in range(1, 100):
	r = n * i + 1
	for j in range(2, r // 2 + 1):
		if r % j == 0:
			print(i)
			c += 1
			break
	if c == 1:
		break


n = int(input())
if n > 2:
	print(n - 2)
if n == 1:
	print(7)
if n == 2:
	print(4)


from math import sqrt
n = int(input())

def is_prime(n: int) -> bool:
	sq = int(sqrt(n)) + 1
	for i in range(2, sq):
		if n % i == 0:
			return False
	return True

def solve(n: int) -> int:
	for m in range(1, 1001):
		ans = n * m + 1
		if not is_prime(ans):
			return m
print(solve(n))


m = int(input())
if m == 1:
	print(5)
elif m == 2:
	print(4)
elif m % 2 != 0:
	print(1)
else:
	print(m - 2)


def answer():
	a = int(input())
	if a < 10:
		print(a + 2)
	else:
		print(a - 2)
answer()


def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True
n = int(input())
if n == 1:
	print(3)
elif n % 2 == 1:
	print(1)
else:
	for i in range(1, 1000):
		num = n * i + 1
		if isPrime(num) == False:
			print(i)
			break


def isprime(n):
	resposta = True
	i = n - 1
	while i > 1:
		if n % i == 0:
			resposta = False
			break
		i -= 1
	return resposta
n = int(input())
controle = 1
while True:
	x = n * controle + 1
	if isprime(x) == False:
		print(controle)
		break
	else:
		controle += 1


def isPrime(x):
	d = 2
	while d * d <= x and x % d != 0:
		d += 1
	return d * d > x
n = int(input())
i = 1
while isPrime(n * i + 1):
	i += 1
print(i)


num = int(input())

def is_prime(n):
	for i in range(2, n):
		if n % i == 0:
			return False
	return True
cont = 1
while True:
	if is_prime(cont * num + 1):
		cont += 1
	else:
		print(cont)
		break


import math

def is_prime(n):
	if n == 2:
		return True
	if n % 2 == 0 or n <= 1:
		return False
	sqr = int(math.sqrt(n)) + 1
	for divisor in range(3, sqr, 2):
		if n % divisor == 0:
			return False
	return True

def m(n):
	for i in range(1, 1001):
		if not is_prime(n * i + 1):
			return i
n = int(input())
print(m(n))


n = int(input())
m = 1
shart = False
if n == 1:
	print(3)
else:
	while (n * m + 1) % 2 != 0:
		for i in range(2, int((n * m + 1) ** 1 / 2)):
			if (n * m + 1) % i == 0:
				shart = True
				break
		if shart:
			break
		else:
			m = m + 1
	print(m)


def solution():
	n = int(input())
	m = 1
	while True:
		buf = m * n + 1
		if ~-2 ** buf % buf < 2:
			m += 1
		else:
			return m
print(solution(), end='')


n = int(input())
m = 1
while m <= 1000:
	i = 2
	while i < n * m + 1:
		if (n * m + 1) % i == 0:
			print(m)
			m = 1001
			break
		i += 1
	m += 1


def isprime(p):
	f = 0
	for (i, j) in enumerate(range(p - 2), start=2):
		if p % i == 0:
			f = 1
	if f == 1 or p == 1:
		return False
	else:
		return True
n = int(input())
m = 1
while True:
	a = n * m + 1
	if isprime(a) == False:
		print(m)
		break
	m = m + 1


def np(a):
	for i in range(2, a):
		if a % i == 0:
			return 1
	else:
		return 0
n = int(input())
for i in range(1, 10 ** 3 + 1):
	if np(n * i + 1):
		print(i)
		break


def eratosphene(n):
	sieve = list(range(n + 1))
	sieve[1] = 0
	for i in sieve:
		if i > 1:
			for j in range(i + i, len(sieve), i):
				sieve[j] = 0
	return list(filter(lambda x: x > 1, sieve))
primes = eratosphene(1000000)
n = int(input())
for i in range(1, 1001):
	if i * n + 1 not in primes:
		print(i)
		break


from math import *

def isprime(n):
	if n == 1:
		return False
	elif n == 2:
		return True
	else:
		for i in range(2, floor(sqrt(n)) + 1):
			if not n % i:
				return False
		return True
n = int(input())
for m in range(1, 1001):
	if not isprime(n * m + 1):
		print(m)
		break


n = int(input())
d = []
e = []
s = 0
i = 1
while True:
	s = n * i + 1
	for j in range(1, s):
		d.append(j)
	for k in range(len(d)):
		f = s % d[k]
		e.append(f)
	if e.count(0) != 1:
		print(i)
		break
	else:
		i += 1
		d = []
		e = []


def iscomposite(N):
	i = 2
	while i * i <= N:
		if N % i == 0:
			return True
		i += 1
(n,) = [int(i) for i in input().split()]
if n == 1:
	print(3)
elif n == 2:
	print(4)
elif n & 1 == 0:
	for i in range(1, 1001):
		if iscomposite(n * i + 1):
			print(i)
			break
else:
	print(1)


from math import *
import sys, random

def nextInt():
	return int(input())

def nextStrs():
	return input().split()

def nextInts():
	return list(map(int, nextStrs()))

def isPrime(x):
	if x == 0 or x == 1:
		return False
	else:
		for i in range(2, x):
			if i * i > x:
				break
			if x % i == 0:
				return False
		return True

def main():
	n = nextInt()
	for i in range(1, 2 * 10 ** 3 + 1):
		if not isPrime(n * i + 1):
			print(i)
			return 0
exit(main())


from operator import itemgetter
n = int(input())
if n % 2 == 1:
	print(7)
else:
	i = n
	num2 = 0
	ans = 1
	for num in range(995, 1100, 5):
		flag = 0
		for j in range(1, 1001):
			if i * j % num == num - 1:
				num2 = j
				flag = 1
				break
		if flag != 0:
			ans = num2
	for num in range(1002, 1200, 3):
		flag = 0
		for j in range(1, 1001):
			if i * j % num == num - 1:
				num2 = j
				flag = 1
				break
		if flag != 0:
			ans = num2
	for num in range(1001, 1200, 7):
		flag = 0
		for j in range(1, 1001):
			if i * j % num == num - 1:
				num2 = j
				flag = 1
				break
		if flag != 0:
			ans = num2
	for num in range(1001, 1200, 11):
		flag = 0
		for j in range(1, 1001):
			if i * j % num == num - 1:
				num2 = j
				flag = 1
				break
		if flag != 0:
			ans = num2
	print(ans)


def sieve(n=10 ** 7):
	s = [-1] * n
	for i in range(2, int(n ** 0.5) + 1):
		if s[i] != -1:
			continue
		for j in range(i, n, i):
			if j > i:
				s[j] = i
	return s

def primes(n=10 ** 7):
	factors = sieve(n)
	return [i for (i, e) in enumerate(factors) if e == -1 and i >= 2]
PRIMES = set(primes(10 ** 6))
n = int(input())
for m in range(1, 1000):
	if n * m + 1 not in PRIMES:
		print(m)
		exit()


prime = [True] * 1000003
for i in range(2, int(1000002 ** 0.5) + 1):
	if prime[i]:
		for j in range(i * 2, 1000003, i):
			prime[j] = False
n = int(input())
for i in range(1, 1001):
	if not prime[n * i + 1]:
		print(i)
		break


import math
n = int(input())
count = 0
if n == 1:
	print(3)
elif n == 2:
	print(4)
elif n % 2 != 0:
	print(1)
else:
	for i in range(1, n + 1):
		count = i
		m = n * i + 1
		for j in range(2, int(math.sqrt(m)) + 1):
			if m % j == 0:
				print(count)
				exit()


def isPrime(n):
	for i in range(2, int(n ** 0.5) + 1):
		if n % i == 0:
			return False
	return True
k = 0
n = int(input())
for i in range(10000):
	c = n * i + 1
	if isPrime(c) == False:
		print(i)
		break


def prost(numb):
	kol_del = False
	elem = 2
	while not kol_del and elem <= int(numb ** 0.5):
		if not numb % elem:
			return False
		elem += 1
	return True
n = int(input())
m = 1
Is = False
while not Is and m <= 10 ** 3:
	Is = not prost(n * m + 1)
	m += 1
print(m - 1)


import sys
sys.setrecursionlimit(10 ** 6)
debug_mode = True if len(sys.argv) > 1 and sys.argv[1] == '-d' else False
if debug_mode:
	import os
	infile = open(os.path.abspath(__file__).replace('.py', '.in'))

	def input():
		return infile.readline()

def sieve(n):
	not_prime = set()
	primes = []
	for i in range(2, n + 1):
		if i not in not_prime:
			primes.append(i)
			for j in range(i * i, n + 1, i):
				not_prime.add(j)
	return primes

def main():
	primes = set(sieve(10 ** 6))
	n = int(input().strip())
	for i in range(n, 10 ** 6 + 2):
		if i in primes:
			continue
		if (i - 1) % n == 0 and (i - 1) // n >= 1:
			print((i - 1) // n)
			return
main()
if debug_mode:
	infile.close()


def is_simple_n(n):
	flag = True
	for i in range(2, n):
		if n % i == 0:
			flag = False
			break
	return flag

def main():
	n = int(input())
	m = 1
	flag = True
	while flag:
		if not is_simple_n(n * m + 1):
			flag = False
			break
		else:
			m += 1
	print(m)
main()


n = int(input())

def isPrime(x):
	for i in range(2, x):
		if x % i == 0:
			return False
	return True
prime = True
m = 0
while prime:
	m += 1
	x = n * m + 1
	prime = isPrime(x)
print(m)


def SieveOfEratosthenes(n):
	prime = [i for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] != 0:
			for i in range(p * p, n + 1, p):
				prime[i] = 0
		p += 1
	return prime

def sol():
	n = int(input())
	A = SieveOfEratosthenes(10000)
	m = 0
	while True:
		m += 1
		if A[n * m + 1] == 0:
			break
	print(m)
sol()


def check_prime(num):
	for i in range(2, int(num ** 0.5) + 1):
		if num % i == 0:
			return False
	return True
n = int(input())
m = 1
num = n * m + 1
while check_prime(num):
	m += 1
	num = n * m + 1
print(m)


n = int(input())
found = False
for m in range(1, 1000 + 1):
	num = n * m + 1
	for i in range(2, int(num ** 0.5) + 1):
		if num % i == 0:
			print(m)
			found = True
			break
	if found:
		break


n = int(input())
import math

def p(x):
	for i in range(2, int(math.sqrt(x) + 1)):
		if x % i == 0:
			return False
	return True
if n == 1:
	print(5)
elif n % 2:
	print(n)
else:
	i = 2
	while p(i * n + 1):
		i += 1
	print(i)


n = int(input())

def pr(a):
	for j in range(2, a):
		if a % j == 0:
			return False
	return True
for i in range(1, 50):
	if pr(n * i + 1) == False:
		break
print(i)


def primesSieve(limit):

	def internalPrimesSieve(limit):
		a = [True] * limit
		a[0] = a[1] = False
		for (i, isprime) in enumerate(a):
			if isprime:
				yield i
				for n in range(i * i, limit, i):
					a[n] = False
	return [p for p in internalPrimesSieve(limit)]
n = int(input())
primes = primesSieve(1000002)
for i in range(1, 1001):
	if n * i + 1 not in primes:
		print(i)
		break


N = int(input())

def CheckPrime(N):
	for i in range(2, N // 2 + 1):
		if N % i == 0:
			return False
	return True
for i in range(1, 100):
	if CheckPrime(i * N + 1) == False:
		print(i)
		break


n = int(input())
if n == 1 or n == 2:
	print(7)
else:
	print(n - 2)


n = int(input())
m = 1
while m < 1000:
	res = n * m + 1
	old = m
	c = 0
	for i in range(2, res):
		if res % i == 0:
			c += 1
			break
	if c != 0:
		break
	else:
		m += 1
print(m)


import math

def ri():
	return map(int, input().split())

def check_prime(num):
	if all((num % i != 0 for i in range(2, int(math.sqrt(num)) + 1))):
		return 1
	else:
		return 0
n = int(input())
for i in range(1, 10 ** 3 + 1):
	if check_prime(n * i + 1) == 0:
		print(i)
		break


n = int(input())
if n % 2 == 1:
	print(999)
elif n % 3 != 0:
	print((n % 3) ** 1 % 3 * 2)
elif n % 5 != 0:
	print((n % 5) ** 3 % 5 * 4)
elif n % 7 != 0:
	print((n % 7) ** 5 % 7 * 6)
else:
	print((n % 11) ** 9 % 11 * 10)


n = int(input())
s = 0

def prime(w):
	k = 0
	for i in range(1, w + 1):
		if w % i == 0:
			k = k + 1
	if k == 2:
		return 1
while True:
	s = s + 1
	w = n * s + 1
	if prime(w) != 1:
		print(s)
		break


def is_prime(x):
	if x == 2:
		return True
	elif x < 2:
		return False
	else:
		if x % 2 == 0:
			return False
		elif any((x % i == 0 for i in range(3, int(x ** 0.5) + 1, 2))):
			return False
		return True
n = int(input())
if n % 2 == 1:
	print(3)
else:
	m = 1
	while is_prime(m * n + 1) == True:
		m += 1
	print(m)


def isprime(num):
	div = 0
	for i in range(1, num + 1):
		if num % i == 0:
			div += 1
	return div == 2

def findInto(num):
	if num == 1:
		return 3
	if num % 2 != 0:
		return 1
	m = 1
	while m > 0:
		if not isprime(num * m + 1):
			return m
		m += 1
num = int(input())
print(findInto(num))


(a, b) = (int(input()), 1)
is_prime = lambda x: all((x % i != 0 for i in range(2, int(x ** 0.5) + 1)))
while True:
	if not is_prime(a * b + 1):
		break
	b += 1
print(b)


def isPrime(n):
	if n == 1:
		return False
	else:
		d = 2
		while d * d <= n:
			if n % d == 0:
				return False
			d = d + 1
		return True
n = int(input().strip())
for m in range(1, 1001):
	if not isPrime(n * m + 1):
		print(m)
		break


n = int(input())
if n % 2 != 0:
	print(3)
elif n == 2:
	print(4)
else:
	print(n - 2)


import math

def primenum(x):
	count = 0
	for i in range(2, int(math.floor(math.sqrt(x))) + 1):
		if x % i == 0:
			count = count + 1
	if count == 0:
		return True
	else:
		return False
n = int(input())
for i in range(1, 1000):
	if primenum(n * i + 1) == False:
		print(i)
		break


def is_prime(num):
	i = 2
	while i ** 2 <= num:
		if num % i == 0:
			return False
		i += 1
	return True

def main():
	n = int(input())
	for m in range(1, 10 ** 3 + 1):
		if not is_prime(n * m + 1):
			print(m)
			return
main()


def simple(n):
	i = 2
	stop = 0
	while stop != 1 and i < int(n ** 0.5) + 1:
		if n % i == 0:
			stop = 1
			return 'NO'
		else:
			i += 1
	if stop != 1:
		return 'YES'
n = int(input())
if n % 2 != 0 and n != 1:
	print(n)
else:
	stop = 0
	i = 1
	while stop != 1:
		if simple(i * n + 1) == 'NO':
			print(i)
			stop = 1
		else:
			i += 1


def isPrime(n):
	if n == 0 or n == 1:
		return False
	i = 2
	while i * i <= n:
		if n % i == 0:
			return False
		i += 1
	return True

def notPrime(n):
	m = 1
	while isPrime(n * m + 1):
		m += 1
	return m
print(notPrime(int(input())))