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

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()


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())

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


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


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


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


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


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


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


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


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


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 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


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 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


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


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()


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

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


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)


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())
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


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()


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()


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


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())


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


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


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())
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))


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())

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


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())
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


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)


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)


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


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


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())
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())
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())
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 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 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


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


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


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


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


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)


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


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)


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)


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


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


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


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)


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


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


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 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))


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


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


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


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)


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


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


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


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)


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()


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()


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


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 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))


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)


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 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 = 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


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))


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())
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


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)


(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


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


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 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)


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


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)


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()


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)


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


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


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))


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)


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())


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())

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())
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())
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 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


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 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())))