Fedya studies in a gymnasium. Fedya's maths hometask is to calculate the following expression:(1^{n} + 2^{n} + 3^{n} + 4^{n}) mod 5

for given value of n. Fedya managed to complete the task. Can you? Note that given number n can be extremely large (e.g. it can exceed any integer type of your programming language).


-----Input-----

The single line contains a single integer n (0 ≤ n ≤ 10^10^5). The number doesn't contain any leading zeroes.


-----Output-----

Print the value of the expression without leading zeros.


-----Examples-----
Input
4

Output
4

Input
124356983594583453458888889

Output
0



-----Note-----

Operation x mod y means taking remainder after division x by y.

Note to the first sample:

[Image]

Source: codeforces | Difficulty: EASY
Tags: Number theory

Mathematics


Solutions:
if int(input()) % 4:
	print(0)
else:
	print(4)


n = int(input())
if n == 0:
	answer = 4
else:
	a = 1
	if n % 4 == 0:
		a += 6 + 1
	elif n % 4 == 1:
		a += 2 + 3
	elif n % 4 == 2:
		a += 4 + 9
	else:
		a += 8 + 7
	if n % 2 == 0:
		a += 6
	else:
		a += 4
	answer = a % 5
print(answer)


n = int(input())
a = 1
b = pow(2, n, 5)
c = pow(3, n, 5)
d = pow(4, n, 5)
e = (a + b + c + d) % 5
print(e)


def main():
	n = int(input())
	real_n = n % 4
	a1 = pow(1, real_n)
	a2 = pow(2, real_n)
	a3 = pow(3, real_n)
	a4 = pow(4, real_n)
	answer = (a1 + a2 + a3 + a4) % 5
	print(answer)
main()


a = int(input())
a = a % 4
b = 1 + 2 ** a + 3 ** a + 4 ** a
b = b % 5
print(b)


n = int(input())
print(sum([pow(i, n, 5) for i in (1, 2, 3, 4)]) % 5)


def f(n):
	r2 = [1, 2, 4, 3]
	r3 = [1, 3, 4, 2]
	r4 = [1, 4]
	return (1 + r2[n % 4] + r3[n % 4] + r4[n % 2]) % 5
n = int(input()[-2:])
print(f(n))


n = input()
if int(n[-1]) % 2 == 1:
	print(0)
else:
	rem = 0
	if len(n) <= 2:
		rem = int(n) % 4
	else:
		rem = int(n[-2:]) % 4
	ans = 2 ** rem
	print(2 * (1 + ans) % 5)


def Remainder(s):
	return 4 if s % 4 == 0 else 0
s = int(input())
print(Remainder(s))


import math
from collections import Counter, defaultdict
I = lambda : int(input())
M = lambda : map(int, input().split())
LI = lambda : list(map(int, input().split()))
n = int(input())
if n % 4 == 0:
	print(4)
else:
	print(0)


z = input
mod = 10 ** 9 + 7
from collections import *
from queue import *
from sys import *
from collections import *
from math import *
from heapq import *
from itertools import *
from bisect import *
from collections import Counter as cc
from math import factorial as f

def lcd(xnum1, xnum2):
	return xnum1 * xnum2 // gcd(xnum1, xnum2)

def prime(x):
	p = ceil(x ** 0.5) + 1
	for i in range(2, p):
		if x % i == 0:
			return 0
	return 1
z = input
mod = 10 ** 9 + 7
from collections import *
from queue import *
from sys import *
from collections import *
from math import *
from heapq import *
from itertools import *
from bisect import *
from collections import Counter as cc
from math import factorial as f

def lcd(xnum1, xnum2):
	return xnum1 * xnum2 // gcd(xnum1, xnum2)

def prime(x):
	p = ceil(x ** 0.5) + 1
	for i in range(2, p):
		if x % i == 0:
			return 0
	return 1
n = 1
for _ in range(n):
	x = int(z())
	if x % 4 == 0:
		print(4)
	else:
		print(0)


N = int(input())
N %= 4
if N == 1 or N == 3 or N == 2:
	print(0)
else:
	print(4)


n = input()
if int(n[-2:]) % 4 == 0:
	print('4')
else:
	print('0')


a = int(input())
if a == 0:
	print(4)
elif a % 4 == 0:
	print(4)
else:
	print(0)


from __future__ import division, print_function
import os
import sys
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip
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 math import sqrt, floor, factorial, gcd, log
from collections import deque, Counter, defaultdict
from itertools import permutations, combinations
from math import gcd
from bisect import bisect
input = lambda : sys.stdin.readline().rstrip('\r\n')
read = lambda : list(map(int, input().strip().split(' ')))

def solve():
	n = int(input())
	dic = [[1], [1, 2, 4, 3], [1, 3, 4, 2], [1, 4]]
	ans = 0
	for i in range(4):
		ans += dic[i][n % len(dic[i])]
		ans %= 5
	print(ans % 5)
solve()


n = int(input())
if n % 2 == 1:
	result = 0
else:
	g = n % 4 + 1
	h = 2 ** g + 2
	result = h % 5
print(result)


n = int(input())
ans = pow(1, n, 5) + pow(2, n, 5) + pow(3, n, 5) + pow(4, n, 5)
ans = ans % 5
print(ans)


s = input()
n = int(s[-2:])
print(sum((i ** n for i in range(1, 5))) % 5)


a = int(input())
if a == 0:
	exit(print(4))
print((1 + [3, 9, 9, 9][a % 4]) % 5)


import sys, math, string, bisect
input = sys.stdin.readline
from collections import deque
L = lambda : list(map(int, input().split()))
Ls = lambda : list(input().split())
M = lambda : map(int, input().split())
I = lambda : int(input())
n = I()
a = [6, 2, 4, 8]
b = [1, 3, 9, 7]
c = [6, 4, 6, 4]
if n == 0:
	print(4)
else:
	n = n % 4
	print((1 + a[n] + b[n] + c[n]) % 5)


N = int(input())
res = 1
if N % 4 == 0:
	res += 1 + 1 + 1
elif N % 3 == 0:
	res += 3 + 2 + 4
elif N % 2 == 0:
	res += 4 + 4 + 1
else:
	res += 2 + 3 + 4
print(res % 5)


n = eval(input())
if n % 4 == 0:
	print(4)
else:
	print(0)


n = int(input())
r = n % 4
print((1 + pow(2, r, 5) + pow(3, r, 5) + pow(4, r, 5)) % 5)


def f(n):
	return sum(map(lambda x: x ** n, range(1, 5))) % 5

def main():
	n = int(input())
	print([4, 0, 0, 0][n % 4])
main()


n = int(input())
ans1 = pow(1, n, 5)
ans2 = pow(2, n, 5)
ans3 = pow(3, n, 5)
ans4 = pow(4, n, 5)
ans = (ans1 + ans2 + ans3 + ans4) % 5
print(ans)


a = input()
if len(a) >= 2:
	b = int(a[-1]) + int(a[-2]) * 10
	if b % 4 == 0:
		print(4)
	else:
		print(0)
elif int(a) % 4 == 0:
	print(4)
else:
	print(0)


n = int(input())
if n == 0:
	print(4)
else:
	l = [6, 2, 4, 8]
	l1 = [1, 3, 9, 7]
	l2 = [6, 4]
	c = 1 + l[n % 4] + l1[n % 4] + l2[n % 2]
	print(c % 5)


n = int(input())
ans = 1
if n % 4 == 0:
	ans += 2
elif n % 4 == 1:
	ans += 5
elif n % 4 == 2:
	ans += 8
else:
	ans += 5
if n == 0:
	ans += 1
elif n % 2 == 1:
	ans += 4
elif n % 2 == 0:
	ans += 1
print(ans % 5)


s = input()
if len(s) >= 2:
	s = s[-2:]
s = int(s)
p = s % 4
r = [1, 1, 1, 1][p]
r += [1, 2, 4, 3][p]
r += [1, 3, 4, 2][p]
r += [1, 4, 1, 4][p]
r %= 5
print(r)


n = int(input())
val = n % 4
ans = (1 ** val % 5 + 2 ** val % 5 + 3 ** val % 5 + 4 ** val % 5) % 5
print(ans)


s = input()
if len(s) > 2:
	s = s[-2:]
n = int(s)
print((1 + 2 ** n + 3 ** n + 4 ** n) % 5)


x = int(input())
if x % 4 == 0:
	print(4)
	exit()
print(0)


a = input()
mas1 = [1, 1, 1, 1]
mas2 = [1, 2, 4, 3]
mas3 = [1, 3, 4, 2]
mas4 = [1, 4, 1, 4]
c = int(a) % 4
print((mas1[c] + mas2[c] + mas3[c] + mas4[c]) % 5)


n = input().strip()
num = 0
if len(n) >= 2:
	num = int(n[-2]) * 10 + int(n[-1])
else:
	num = int(n)
if num % 4 == 0:
	print(4)
else:
	print(0)


s = '0' + str(input())
i = int(s[-1]) + int(s[-2]) * 10
if i % 4 == 0:
	print('4')
else:
	print('0')


from math import *
n = int(input())
if n % 4 == 0:
	a = 1
	b = 1
elif n % 4 == 1:
	a = 2
	b = 3
elif n % 4 == 2:
	a = 4
	b = 4
elif n % 4 == 3:
	a = 3
	b = 2
if n % 2 == 0:
	c = 1
else:
	c = 4
x = a + b + c + 1
print(x % 5)


i = int(input())
l1 = [1, 1, 1, 1]
l2 = [1, 2, 4, 8]
l3 = [1, 3, 4, 2]
l4 = [1, 4, 1, 4]
i = i % 4
print((l1[i] + l2[i] + l3[i] + l4[i]) % 5)


n = input()
b = int(n) % 4
total = 1
total = total + 2 ** b % 5 + 3 ** b % 5 + 4 ** b % 5
total = total % 5
print(total)


y = int(input())
x = y % 4
if x == 0:
	print((1 + 1 + 1 + 1) % 5)
if x == 1:
	print((1 + 2 + 3 + 4) % 5)
if x == 2:
	print((1 + 4 + 4 + 1) % 5)
if x == 3:
	print((1 + 3 + 2 + 4) % 5)


s = input()
x = 0
if len(s) is 1:
	x = int(s[0])
else:
	x = int(s[len(s) - 2]) * 10 + int(s[len(s) - 1])
print([4, 0][x % 4 != 0])


def solve():
	n = int(input())
	if n % 4 == 0:
		print('4')
	else:
		print('0')
solve()


n = int(input())
p = n % 4
print((1 ** p + 2 ** p + 3 ** p + 4 ** p) % 5)


from sys import stdin
stdin.readline

def mp():
	return list(map(int, stdin.readline().strip().split()))

def it():
	return int(stdin.readline().strip())
n = it()
a = pow(2, n, 5)
b = pow(3, n, 5)
c = pow(4, n, 5)
x = (1 + a + b + c) % 5
print(x)


s = int(input())
s = s % 1000000000
if s % 4 == 0:
	print(4)
else:
	print(0)


import math
import itertools
import collections

def getdict(n):
	d = {}
	if type(n) is list:
		for i in n:
			if i in d:
				d[i] += 1
			else:
				d[i] = 1
	else:
		for i in range(n):
			t = ii()
			if t in d:
				d[t] += 1
			else:
				d[t] = 1
	return d

def cdiv(n, k):
	return n // k + (n % k != 0)

def ii():
	return int(input())

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

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

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

def wr(arr):
	return ' '.join(map(str, arr))

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

def revn(n):
	m = 0
	while n > 0:
		m = m * 10 + n % 10
		n = n // 10
	return m
print(4) if int(input()[-2:]) % 4 == 0 else print(0)


phi = 4
n = int(input()[-2:])
n %= phi
ans = (1 ** n + 2 ** n + 3 ** n + 4 ** n) % 5
print(ans)


a = [1, 1, 1, 1]
b = [2, 4, 3, 1]
c = [3, 4, 2, 1]
d = [4, 1, 4, 1]

def main():
	n = int(input()) - 1
	i = n % 4
	e = a[i] + b[i] + c[i] + d[i]
	print(e % 5)
main()


n = list(map(int, input()))
l = len(n)
if n[l - 1] % 2 == 1:
	print(0)
elif l == 1:
	print(2 * (1 + 2 ** n[0]) % 5)
else:
	r = (10 * n[l - 2] + n[l - 1]) % 4
	print(2 * (1 + 2 ** r) % 5)


n = input()
if len(n) < 2:
	n = '0' + n
s = n[-2] + n[-1]
s = int(s)
if s % 4 == 0:
	print(4)
else:
	print(0)


line = input()
end = ''
if len(line) == 1:
	end = line
else:
	end = line[-2:]
if int(end) % 4 == 0:
	print(4)
else:
	print(0)


n = int(input())
if n == 0:
	print(4)
else:
	end = 0
	end += 1
	h = n % 4
	if h == 3:
		end += 2
		end += 3
	if h == 2:
		end += 4
		end += 9
	if h == 1:
		end += 8
		end += 27
	if h == 0:
		end += 16
		end += 81
	if n % 2 == 1:
		end += 4
	if n % 2 == 0:
		end += 6
	print(end % 10 % 5)


n = int(input())
a1 = [1, 1, 1, 1]
a2 = [2, 4, 3, 1]
a3 = [3, 4, 2, 1]
a4 = [4, 6, 4, 6]
k = n % 4 - 1
print((a1[k] + a2[k] + a3[k] + a4[k]) % 5)


s = input()
x = int(s[-2:])
if x % 4 == 0:
	print(4)
else:
	print(0)


import sys
n = int(input())
if n % 4 == 0:
	print(4)
else:
	print(0)


n = int(input())
(a, b, c, d) = (0, 0, 0, 0)
if n % 4 == 1:
	(a, b, c, d) = (1, 2, 3, 4)
if n % 4 == 2:
	(a, b, c, d) = (1, 4, 9, 6)
if n % 4 == 3:
	(a, b, c, d) = (1, 8, 7, 4)
if n % 4 == 0:
	(a, b, c, d) = (1, 6, 1, 6)
ans = (a + b + c + d) % 5
print(ans)


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, 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 [int(x) for x in sys.stdin.readline().split()]

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)

def main():
	s = S()
	n = int(s[-2:])
	t = 0
	for i in range(1, 5):
		t += i ** n
	return t % 5
print(main())


n = int(input())

def BINPOW(a, b):
	if b == 0:
		return 1
	if b == 1:
		return a
	if b % 2 == 0:
		val = BINPOW(a, b / 2)
		return val * val
	else:
		return BINPOW(a, b - 1) * a
n = n % 4
print((1 + BINPOW(2, n) + BINPOW(3, n) + BINPOW(4, n)) % 5)


def main():
	print(4 if not int(input().strip()[-2:]) % 4 else 0)
main()


n = input()
if int(n) < 10:
	t = int(n)
else:
	t = int(n[-1]) + 10 * int(n[-2])
print(4 if t % 4 == 0 else 0)


two = [1, 2, 4, 3]
three = [1, 3, 4, 2]
four = [1, 4, 1, 4]
n = input().strip()
n = int(n[len(n) - 2:])
k = 1 + two[n % 4] + three[n % 4] + four[n % 4]
print(k % 5)


n = int(input())
mod1 = n % 4
temp = 0
temp2 = 0
if mod1 == 0:
	temp = 1
	temp2 = 1
elif mod1 == 1:
	temp = 2
	temp2 = 3
elif mod1 == 2:
	temp = 4
	temp2 = 4
elif mod1 == 3:
	temp = 3
	temp2 = 2
res = 1 + temp + temp * temp + temp2
print(res % 5)


a = int(input())
b = 1
if a % 4 == 0:
	print(4)
else:
	print(0)


n = int(input())
temp = n % 4
if temp == 0:
	print('4')
else:
	print('0')


import sys
import io
import os
total = 0
failed = 0

def debug(a):
	print(a, file=sys.stderr)

def run(test, res):
	x = io.StringIO()
	with io.StringIO(test) as sys.stdin:
		with x as sys.stdout:
			work()
			z = x.getvalue().strip()
	sys.stdout = sys.__stdout__
	print('Passed?', z == res)
	print('Expected: ', res)
	print('Actual  : ', z)
	global total, failed
	total += 1
	failed += 1 if z != res else 0

def work():
	s = input()
	n = int(s[len(s) - 2:])
	print(4 if n % 4 == 0 else 0)

def test():
	run('1', '0')
	run('2', '0')
	run('3', '0')
	run('4', '4')
	run('5', '0')
	run('8', '4')
	run('124356983594583453458888889', '0')
if 'LOCALTEST' in os.environ:
	test()
	print('\n Result: %s (%d total, %d failed)' % ('FAILED' if failed > 0 else 'PASSED', total, failed))
else:
	work()


import sys
import math
import itertools
import functools
import collections
import operator
import fileinput
import copy
ORDA = 97

def ii():
	return int(input())

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

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

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

def revn(n):
	return str(n)[::-1]

def dd():
	return collections.defaultdict(int)

def ddl():
	return collections.defaultdict(list)

def sieve(n):
	if n < 2:
		return list()
	prime = [True for _ in range(n + 1)]
	p = 3
	while p * p <= n:
		if prime[p]:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 2
	r = [2]
	for p in range(3, n + 1, 2):
		if prime[p]:
			r.append(p)
	return (r, prime)

def divs(n, start=2):
	r = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				r.append(i)
			else:
				r.extend([i, n // i])
	return r

def divn(n, primes):
	divs_number = 1
	for i in primes:
		if n == 1:
			return divs_number
		t = 1
		while n % i == 0:
			t += 1
			n //= i
		divs_number *= t

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

def convn(number, base):
	new_number = 0
	while number > 0:
		new_number += number % base
		number //= base
	return new_number

def cdiv(n, k):
	return n // k + (n % k != 0)

def ispal(s):
	for i in range(len(s) // 2 + 1):
		if s[i] != s[-i - 1]:
			return False
	return True

def main():
	n = ii()
	if n % 4 == 0:
		print(4)
	else:
		print(0)
main()


import sys
n = sys.stdin.readline().split('\n')[0]
n = int(n[-2:])
if n % 4 == 0:
	print(4)
else:
	print(0)


n = int(input())
c = n % 4
print((1 + 2 ** c + 3 ** c + 4 ** c) % 5)


n = input()
if len(n) >= 2:
	temp = int(n[len(n) - 2] + n[len(n) - 1])
	if temp % 4 == 0:
		print(4)
	else:
		print(0)
else:
	temp = int(n[len(n) - 1])
	if temp % 4 == 0:
		print(4)
	else:
		print(0)


n = str(input())
last = int(n[-2:])
if last % 4 == 0:
	print(4)
else:
	print(0)


import math
import string

def main():
	n = int(input())
	print((1 + pow(2, n, 5) + pow(3, n, 5) + pow(4, n, 5)) % 5)
main()


def main():
	N = input()
	if len(N) == 1 and N[0] == '0':
		print(4)
	else:
		if len(N) == 1:
			nMod4 = int(N) % 4
		else:
			nMod4 = int(N[-2:]) % 4
		nMod2 = int(N[-1]) % 2
		print((1 % 5 + [2, 4, 8, 6][nMod4 - 1] % 5 + [3, 9, 7, 1][nMod4 - 1] % 5 + [4, 6][nMod2 - 1] % 5) % 5)
main()


n = int(input())
p2 = [1, 2, 4, 3]
p3 = [1, 3, 4, 2]
p4 = [1, 4]
ans = 1 + p2[n % 4] + p3[n % 4] + p4[n % 2]
print(ans % 5)


def solve():
	from sys import stdin
	line = stdin.readline
	n = int(line())
	n = 1 + pow(2, n, 5) + pow(3, n, 5) + pow(4, n, 5)
	print(n % 5)
	return
solve()


l2 = [1, 2, 4, 3]
l3 = [1, 3, 4, 2]
l4 = [1, 4]
n = int(input())
mod = 1 + l2[n % 4] + l3[n % 4] + l4[n % 2]
mod = (mod % 5 + 5) % 5
print(mod)


from sys import stdin, stdout
from collections import Counter
from math import ceil
from bisect import bisect_left
from bisect import bisect_right
import math
ai = lambda : list(map(int, stdin.readline().split()))
ei = lambda : map(int, stdin.readline().split())
ip = lambda : int(stdin.readline().strip())
M = 5

def modularExponentiation(x, n):
	n = n % 4
	if n == 0:
		return 1
	elif n % 2 == 0:
		return modularExponentiation(x * x % M, n // 2)
	else:
		return x * modularExponentiation(x * x % M, (n - 1) // 2) % M
n = ip()
(one, two, three, four) = (modularExponentiation(1, n), modularExponentiation(2, n), modularExponentiation(3, n), modularExponentiation(4, n))
print((one % 5 + two % 5 + three % 5 + four % 5) % 5)


n = int(input())
two = [2, 4, 8, 6]
three = [3, 9, 7, 1]
four = [4, 6, 4, 6]
ni = (n - 1) % 4
ans = 1 + two[ni] + three[ni] + four[ni]
print(ans % 5)


s = input()
a = int(s[-2:]) % 4
if a == 0:
	print(4)
else:
	print(0)


n = int(input())
if n == 0:
	print(4)
else:
	s = 0
	l2 = [2, 4, 8, 6]
	l3 = [3, 9, 7, 1]
	l4 = [4, 6]
	s = s + l2[(n - 1) % 4] + l3[(n - 1) % 4] + 1
	s = s + l4[(n - 1) % 2]
	print(s % 5)


import sys
import math

def main():
	n = int(sys.stdin.readline().strip()) % 4
	print((1 + 2 ** n % 5 + 3 ** n % 5 + 4 ** n % 5) % 5)
main()


n = int(input())
z = n % 4
print((pow(1, z) + pow(2, z) + pow(3, z) + pow(4, z)) % 5)


n = int(input())
ans = n % 4
a2 = (1, 2, 4, 3)
a3 = (1, 3, 4, 2)
a4 = (1, 4, 1, 4)
print((1 + a2[ans] + a3[ans] + a4[ans]) % 5)


d = {1: [1, 1, 1, 1], 2: [2, 4, 8, 6], 3: [3, 9, 7, 1], 4: [4, 6, 4, 6], 5: [5, 5, 5, 5], 6: [6, 6, 6, 6], 7: [7, 9, 3, 1], 8: [8, 4, 2, 6], 9: [9, 1, 9, 1], 0: [0, 0, 0, 0]}
k = input()
t = 10 * int(k[len(k) - 2]) + int(k[len(k) - 1])
t = t % 4
sumfin = 0
for i in range(1, 5):
	if t != 0:
		sumfin = sumfin + d[i % 10][t - 1]
	elif t == 0:
		sumfin = sumfin + d[i % 10][3]
print(sumfin % 5)


import re
import sys
from bisect import bisect, bisect_left, insort, insort_left
from collections import Counter, defaultdict, deque
from copy import deepcopy
from decimal import Decimal
from itertools import accumulate, combinations, combinations_with_replacement, groupby, permutations, product
from math import acos, asin, atan, ceil, cos, degrees, factorial, gcd, hypot, log2, pi, radians, sin, sqrt, tan
from operator import itemgetter, mul
from string import ascii_lowercase, ascii_uppercase, digits

def inp():
	return int(input())

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

def instr():
	s = input()
	return list(s[:len(s)])

def invr():
	return map(int, input().split())
s = input()
if len(s) < 2:
	n = int(s)
	if n % 4 == 0:
		print(4)
	else:
		print(0)
else:
	n = int(s[-2:])
	if n % 4 == 0:
		print(4)
	else:
		print(0)


s = input()
if len(s) > 2:
	s = s[-2:]
n = int(s)
print((1 + 2 ** n + 3 ** n + 4 ** n) % 5)
exit()
n = int(input())
for i in range(n):
	(x, y) = map(int, input().split())
	if x != y:
		print('Happy Alex')
		exit()
print('Poor Alex')


x = int(input())
if x == 0:
	print(4)
	exit()
a = (x - 1) % 4
b = (x - 1) % 2
print((1 + [2, 4, 3, 1][a] + [3, 4, 2, 1][a] + [4, 1][b]) % 5)


n = int(input())
a2 = [6, 2, 4, 8]
a3 = [1, 3, 9, 7]
a4 = [6, 4]
if n == 0:
	print(4)
else:
	print((1 + a2[n % 4] + a3[n % 4] + a4[n % 2]) % 5)


import math
x = int(input())
print((pow(1, x, 5) + pow(2, x, 5) + pow(3, x, 5) + pow(4, x, 5)) % 5)


import math
n = input()
if len(n) >= 2:
	k = int(n[len(n) - 1]) + int(n[len(n) - 2]) * 10
else:
	k = int(n[len(n) - 1])
r1 = k % 4
r2 = k % 2
count = 0
if r1 == 0:
	count = count + 8
elif r1 == 1:
	count = count + 6
elif r1 == 2:
	count = count + 14
else:
	count = count + 16
if r2 == 0:
	count = count + 6
else:
	count = count + 4
print(count % 5)


a = int(input())
x = int(1)
if a % 4 == 0:
	print(4)
else:
	print(0)


n = int(input())
if n % 2:
	print(0)
else:
	print((2 + 2 ** (n % 4 + 1)) % 5)


def main():
	n = int(input()[-2:])
	print(4 if n % 4 == 0 else 0)
main()


n = int(input())
a = [1, 2, 4, 3]
b = [1, 3, 4, 2]
c = [1, 4]
ans = 1 + c[n % 2] + b[n % 4] + a[n % 4]
print(ans % 5)


n = input()
n = '0' + n
x = int(n[-1])
if x % 2 == 0:
	f = 6
else:
	f = 4
t = int(n[-2])
if t % 2 == 0:
	two = 2 ** (x % 4)
	three = 3 ** (x % 4)
else:
	two = 2 ** (x % 4 + 2)
	three = 3 ** (x % 4 + 2)
ans = 1 + two % 5 + three % 5 + f % 5
print(ans % 5)


n = int(input())
k = (1 + 2 ** (n % 4 + 4) % 10 + 3 ** (n % 4 + 4) % 10 + 4 ** (n % 2 + 2)) % 5
print(k)


n = int(input())
x = (1 + pow(2, n, 5) + pow(3, n, 5) + pow(4, n, 5)) % 5
print(x)


import math
n = int(input())
ans = (pow(1, n, 5) + pow(2, n, 5) + pow(3, n, 5) + pow(4, n, 5)) % 5
print(ans)


print((int(input()) % 4 == 0) * 4)


n = input()
print(4 if int(str(''.join(n[-min(len(n), 2):]))) % 4 == 0 else 0)


number = int(input())
number = number % 4
values = {}
values[1] = [1, 1, 1, 1]
values[2] = [1, 2, 4, 3]
values[3] = [1, 3, 4, 2]
values[4] = [1, 4, 1, 4]
ans = 0
for i in range(1, 5):
	ans = (ans + values[i][number]) % 5
	pass
print(ans)


n = input()
if n == 0:
	print(4)
else:
	d = int(n[-2:])
	if d % 4 == 0:
		print(4)
	elif d % 4 == 1 or d % 4 == 2 or d % 4 == 3:
		print(0)
	else:
		print(3)


entrada = input()
qnt = len(entrada)
x = entrada[qnt - 1]
y = entrada[qnt - 2]
uni = int(x)
dec = 0
if qnt > 1:
	uni = int(x)
	dec = int(y)
j = uni + 10 * dec
if j % 4 == 0:
	print(4)
else:
	print(0)


def sol(a, b):
	ans = 1
	for i in range(b):
		ans = ans * a % 5
	return ans
n = int(input()) % 4
ans = 0
for i in range(1, 5):
	ans = (sol(i, n) + ans) % 5
print(ans)


n = int(input()) % 4
s = 1 + 2 ** n + 3 ** n + 4 ** n
print(s % 5)


n = input()
if len(n) > 2:
	lastTwo = n[-2:]
else:
	lastTwo = n
modifier = int(lastTwo) % 4
totalScore = 1
if modifier == 0:
	totalScore = 1 + 6 + 1 + 6
if modifier == 1:
	totalScore = 1 + 2 + 3 + 4
if modifier == 2:
	totalScore = 1 + 4 + 9 + 6
if modifier == 3:
	totalScore = 1 + 8 + 7 + 4
print(totalScore % 5)


n = input()
if len(n) == 1:
	n = int(n)
	print((1 ** n + 2 ** n + 3 ** n + 4 ** n) % 5)
else:
	l = 1
	k = int(n[-2:])
	for2 = {1: 2, 2: 4, 3: 8, 0: 6}
	for3 = {1: 3, 2: 9, 3: 7, 0: 1}
	for4 = {1: 4, 0: 6}
	l += for2[k % 4] + for3[k % 4] + for4[k % 2]
	print(l % 5)


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


n = '0' + input()
x = int(n[-2:])
ans = 1 + 2 ** (x % 4) + 3 ** (x % 4) + 4 ** (x % 4)
ans = ans % 5
print(ans)


n = int(input())
d = [0, 10, 20, 20, 14]
m = n % 4
if m == 0:
	m = 4
print(d[m] % 5)


n = int(input())
q = 1 + pow(2, n, 5) + pow(3, n, 5) + pow(4, n, 5)
print(q % 5)


n = int(input())
print(sum((pow(x, n, 5) for x in range(1, 5))) % 5)


str = input()
if len(str) >= 2:
	n = int(str[-2] + str[-1])
elif len(str) == 1:
	n = int(str[0])
a2 = [1, 2, 4, 3]
a3 = [1, 3, 4, 2]
a4 = [1, 4]
print((1 + a2[n % 4] + a3[n % 4] + a4[n % 2]) % 5)


t = input()
if int(t[::-1][0:2][::-1]) % 4 == 0:
	print('4')
else:
	print('0')


s = input()
c = s[len(s) - 2:len(s):1]
a = int(c)
if a % 4 == 0:
	print(4)
else:
	print(0)


n = input()
l = int(n[-2:]) % 4
res = 1
if l == 1:
	res += 2
elif l == 2:
	res += 4
elif l == 3:
	res += 8
else:
	res += 6
if l % 2 == 0:
	res += 6
else:
	res += 4
if l == 0:
	res += 1
elif l == 1:
	res += 3
elif l == 2:
	res += 9
else:
	res += 7
res = res % 5
print(res)


num = int(input())
if num % 4 == 0:
	print(4)
elif num % 4 != 0:
	print(0)


import sys, math, bisect
inf = float('inf')
mod = 998244353

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

def gcd(a, b):
	return int(math.gcd(a, b))

def tobinary(n):
	return bin(n)[2:]

def binarySearch(a, x):
	i = bisect.bisect_left(a, x)
	if i != len(a) and a[i] == x:
		return i
	else:
		return -1

def lowerBound(a, x):
	i = bisect.bisect_left(a, x)
	if i:
		return i - 1
	else:
		return -1

def upperBound(a, x):
	i = bisect.bisect_right(a, x)
	if i != len(a) + 1 and a[i - 1] == x:
		return i - 1
	else:
		return -1

def primesInRange(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 + 1):
		if prime[p]:
			ans.append(p)
	return ans

def primeFactors(n):
	factors = []
	while n % 2 == 0:
		factors.append(2)
		n = n // 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			factors.append(i)
			n = n // i
	if n > 2:
		factors.append(n)
	return factors
from collections import deque, defaultdict, Counter
import heapq, string

def rotate(s, x):
	s = list(s)
	if len(s) % 2 != (x + 1) % 2:
		return s[x:] + s[:x]
	else:
		return s[x:] + s[:x][::-1]
for _ in range(1):
	n = int(input())
	if n % 4 == 0:
		print(4)
	else:
		print(0)


import os
import sys
from io import BytesIO, IOBase
from math import ceil, floor, pow, sqrt, gcd
from collections import Counter, defaultdict
from itertools import permutations, combinations
from time import time, sleep
BUFSIZE = 8192
MOD = 1000000007

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')
(stdin, stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
from os import path
if path.exists('tc.txt'):
	stdin = open('tc.txt', 'r')

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

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

def gari():
	return list(map(int, stdin.readline().strip().split()))

def gart():
	return tuple(map(int, stdin.readline().strip().split()))

def gars():
	return list(map(str, stdin.readline().strip().split()))

def gs():
	return stdin.readline().strip()

def gls():
	return list(stdin.readline().strip())

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

def pri(i, end='\n'):
	stdout.write(f'{i}' + end)

def priar(ar, end='\n'):
	stdout.write(' '.join(map(str, ar)) + end)

def prist(s, end='\n'):
	stdout.write(''.join(map(str, s)) + end)

def solve():
	n = gi()
	return 0 if n % 4 else 4
tc = 1
while tc:
	tc -= 1
	ans = solve()
	pri(ans)


n = int(input())
out = (1 + pow(2, n, 5) + pow(3, n, 5) + pow(4, n, 5)) % 5
print(out)


s = input()
val = int(s)
ans = 1 + 2 ** (val % 4) + 3 ** (val % 4) + 4 ** (val % 4)
print(ans % 5)


n = eval(input())
n = n % 4
print((1 ** n + 2 ** n + 3 ** n + 4 ** n) % 5)


from collections import deque as de

class My_stack:

	def __init__(self):
		self.data = []

	def my_push(self, x):
		return self.data.append(x)

	def my_pop(self):
		return self.data.pop()

	def my_peak(self):
		return self.data[-1]

	def my_contains(self, x):
		return self.data.count(x)

	def my_show_all(self):
		return self.data

	def isEmpty(self):
		return len(self.data) == 0
arrStack = My_stack()

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 % 4 == 0:
	print(4)
else:
	print(0)


dic3 = {1: 3, 2: 9, 3: 7, 0: 1}
dic2 = {1: 2, 2: 4, 3: 8, 0: 6}
dic4 = {1: 4, 2: 6, 3: 4, 0: 6}
s = input()
l = len(s)
if l == 1:
	s = int(s)
else:
	s = int(s[-2] + s[-1])
m = s % 4
print((1 + dic2[m] + dic3[m] + dic4[m]) % 5)


n = int(input())
if n % 4 == 0:
	print(4)
if n % 4 != 0:
	print(0)


a = int(input())
print(sum(list(map(lambda x: x ** (a % 4), range(1, 5)))) % 5)


n = int(input())
c2 = [1, 2, 4, 3]
c3 = [1, 3, 4, 2]
c4 = [1, 4]
a1 = 1
a2 = c2[n % 4]
a3 = c3[n % 4]
a4 = c4[n % 2]
print((a1 + a2 + a3 + a4) % 5)


n = int(input())
listmod2 = [6, 2, 4, 8]
listmod3 = [1, 3, 9, 7]
listmod4 = [6, 4]
mod1 = 1
mod2 = listmod2[n % 4]
mod3 = listmod3[n % 4]
mod4 = listmod4[n % 2]
print((mod1 + mod2 + mod3 + mod4) % 5)


a = input()
b = int(a[-2:len(a)])
c = (1 + 2 ** b + 3 ** b + 4 ** b) % 5
print(c)


n = input()
if len(n) > 1:
	if int(n[-2:len(n)]) % 4 == 0:
		print('4')
	else:
		print('0')
elif int(n) % 4 == 0:
	print('4')
else:
	print('0')


X = int(input())
x = X % 4
print((1 + 2 ** x + 3 ** x + 4 ** x) % 5)


n = int(input())
n = n % 4
if n == 0:
	print('4')
if n == 1 or n == 2 or n == 3:
	print('0')


n = int(input())
mod_1 = [1]
mod_2 = [6, 2, 4, 8]
mod_3 = [1, 3, 9, 7]
mod_4 = [6, 4]
ans = (mod_1[n % 1] + mod_2[n % 4] + mod_3[n % 4] + mod_4[n % 2]) % 5
print(ans)


L = [1, 2, 4, 3]
L1 = [1, 3, 4, 2]
L3 = [1, 4]
n = int(input())
suma = L[n % 4] + L1[n % 4] + L3[n % 2] + 1
print(suma % 5)


n = input()
num = int(n[len(n) - 2] + n[len(n) - 1])
num = num % 4
ans = (1 + pow(2, num) + pow(3, num) + pow(4, num)) % 5
print(ans)


n = int(input())
if n % 2 == 1:
	print(0)
elif n % 4 == 0:
	print(4)
elif n % 4 == 2:
	print(0)


__author__ = 'nikolay'
s = input()
d = int(s[-2:]) % 4
two = [1, 2, 4, 3]
three = [1, 3, 4, 2]
four = [1, 4]
ans = (1 + two[d] + three[d] + four[d % 2]) % 5
print(ans)


import sys
input = sys.stdin.readline
r = int(input()) % 4
if r == 0:
	print(4)
	sys.exit()
else:
	print(0)
	sys.exit()


n = input('')

def check(a):
	res = 0
	b = len(a)
	for i in range(b):
		res = (res * 10 + int(a[i])) % 4
	return res % 4

def expo(x, n):
	total = 1
	while n > 0:
		if n % 2 == 1:
			total = total * x % 5
		else:
			x = x * x % 5
		n = n / 2
	return total
p = check(n)
z = 0
z = z + expo(2, p) % 5
z = z + expo(3, p) % 5
z = z + expo(4, p) % 5
z = z + 1
z = z % 5
print(z)


import sys
from math import *

def solve():
	s = str(input())
	x = 0
	if len(s) > 1:
		x = 10 * int(s[-2]) + int(s[-1])
	else:
		x = int(s[0])
	if x % 4:
		print(0)
	else:
		print(4)
solve()


def main():
	print((4, 0)[int(input()[-2:]) & 3 > 0])
main()


s = input()
ans = 1
temp = len(s)
if temp >= 2:
	temp2 = int(s[temp - 2:temp])
	if temp2 % 4 == 0:
		ans += 7
	else:
		ans += 2 ** (temp2 % 4)
		ans += 3 ** (temp2 % 4)
else:
	ans += 2 ** int(s) + 3 ** int(s)
if int(s[temp - 1]) % 2 == 0:
	ans += 6
else:
	ans += 4
print(ans % 5)


mod5 = {1: [1, 1, 1, 1], 2: [1, 2, 4, 3], 3: [1, 3, 4, 2], 4: [1, 4, 1, 4]}
n = input()
n_last2 = int(n[-2:])
n_mod4 = n_last2 % 4
answer = 0
for i in range(1, 5):
	answer += mod5[i][n_mod4]
answer = answer % 5
print(answer)


n = input()
if int(n) == 0:
	print(4)
else:
	f = 1
	x = int(n) % 4
	if x == 3:
		f += 8
	elif x == 1:
		f += 2
	elif x == 2:
		f += 4
	else:
		f += 6
	y = int(n) % 4
	if y == 0:
		f += 1
	elif y == 1:
		f += 3
	elif y == 2:
		f += 9
	else:
		f += 7
	z = int(n[-1])
	if z % 2 == 0:
		f += 6
	else:
		f += 4
	print(f % 5)


a = int(input())
s = 1
if a % 4 == 0:
	s += 2
elif a % 4 == 1:
	s += 5
elif a % 4 == 2:
	s += 8
elif a % 4 == 3:
	s += 5
s = s * 1
if a % 2 == 0:
	s += 1
elif a % 2 == 1:
	s += 4
print(s % 5)


n = int(input())
j = n
one = 1
if j % 4 == 0:
	two = 1
	three = 1
	four = 1
elif j % 4 == 1:
	two = 2
	four = 4
	three = 3
elif j % 4 == 2:
	two = 4
	three = 4
	four = 1
elif j % 4 == 3:
	two = 3
	three = 2
	four = 4
print((one + two + three + four) % 5)


n = int(input()[-2:])
print(4 * (n % 4 == 0))


from sys import stdin
inFile = stdin
tokens = []
tokens_next = 0

def next_str():
	global tokens, tokens_next
	while tokens_next >= len(tokens):
		tokens = inFile.readline().split()
		tokens_next = 0
	tokens_next += 1
	return tokens[tokens_next - 1]

def nextInt():
	return int(next_str())
n = nextInt()
res = sum([pow(i, n, 5) for i in range(1, 5)]) % 5
print(res)


from sys import stdin
n = int(stdin.readline())
if n % 4 == 0:
	print(4)
else:
	print(0)


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

def bin1(l, r, k, t, b, val, ans):
	if l > r:
		return ans
	else:
		mid = (l + r) // 2
		v = k ** mid
		if v == val:
			return v
		elif v > val:
			ans = mid
			return bin1(mid + 1, r, k, t, b, val, ans)
		else:
			return bin1(l, mid - 1, k, t, b, val, ans)

def bin2(l, r, k, t, b, val, ans):
	if l > r:
		return ans
	else:
		mid = (l + r) // 2
		v = t * k ** mid + b * mid
		if v == val:
			return v
		elif v > val:
			ans = mid
			return bin2(l, mid - 1, k, t, b, val, ans)
		else:
			return bin2(mid + 1, r, k, t, b, val, ans)

def SieveOfEratosthenes(n):
	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
	l = []
	for i in range(2, n + 1):
		if prime[i]:
			l.append(i)
	return l

def bin(l, r, ll, val):
	if l > r:
		return -1
	else:
		mid = (l + r) // 2
		if val >= ll[mid][0] and val <= ll[mid][1]:
			return mid
		elif val < ll[mid][0]:
			return bin(l, mid - 1, ll, val)
		else:
			return bin(mid + 1, r, ll, val)

def deci(n):
	s = ''
	while n != 0:
		if n % 2 == 0:
			n = n // 2
			s = '0' + s
		else:
			n = n // 2
			s = '1' + s
	return s

def diff(s1, s2):
	if len(s1) < len(s2):
		v = len(s1)
		while v != len(s2):
			s1 = '0' + s1
			v = v + 1
	else:
		v = len(s2)
		while v != len(s1):
			s2 = '0' + s2
			v = v + 1
	c = 0
	for i in range(len(s1)):
		if s1[i:i + 1] != s2[i:i + 1]:
			c = c + 1
	return c
from sys import stdin, stdout

def fac(a, b):
	v = a
	while a != b:
		v *= a - 1
		a = a - 1
	return v

def bino(l, r, n):
	if l > r:
		return -1
	else:
		mid = (l + r) // 2
		val1 = math.log(n / mid + 1, 2)
		val2 = int(val1)
		if val1 == val2:
			return val1
		elif val1 < 1.0:
			return bino(l, mid - 1, n)
		else:
			return bino(mid + 1, r, n)

def binary(l, r, ll, val, ans):
	if l > r:
		return ans
	else:
		mid = (l + r) // 2
		if val % ll[mid] == 0:
			ans = ll[mid]
			return binary(l, mid - 1, ll, val, ans)
		else:
			return binary(l, mid - 1, ll, val, ans)

def odd(n, ans, s):
	if n % 2 != 0 or n in s:
		return ans
	else:
		s.add(n)
		return odd(n // 2, ans + 1, s)
n = int(input())
if n % 4 == 0:
	print(4)
else:
	print(0)


N = input()
l = len(N)
ans = 0
if l == 1:
	last = int(N[-1])
else:
	last = int(N[-2:])
ans += 1
ans += [1, 2, 4, 3][last % 4]
ans += [1, 3, 4, 2][last % 4]
ans += [1, 4][last % 2]
ans = ans % 5
print(ans)


x = input()
x = int(x)
y = x % 4
print((1 ** y + 2 ** y + 3 ** y + 4 ** y) % 5)


def sol(n):
	if len(n) == 1 and int(n) == 0:
		print(4)
		return
	s = 1
	l = int(n[-2:]) % 4
	if l == 0:
		s += 6
	else:
		s += 2 ** l
	s += 3 ** l
	if int(n[-1:]) % 2 == 0:
		s += 6
	else:
		s += 4
	print(s % 5)
n = input()
sol(n)


n = input()
if int(n[-1]) % 2 == 1:
	print('0')
elif len(n) >= 2:
	if (int(n[-1]) + 10 * int(n[-2])) % 4 == 0:
		print('4')
	else:
		print('0')
elif int(n[-1]) == 4 or int(n[-1]) == 8 or int(n[-1]) == 0:
	print('4')
else:
	print('0')


n = input()
x = [(1, 1, 1, 1), (1, 2, 4, 3), (1, 3, 4, 2), (1, 4, 1, 4)]
n = int(n)
n = n % 4
l = (x[0][n] + x[1][n] + x[2][n] + x[3][n]) % 5
print(l)


n = int(input())
l2 = [16, 2, 4, 8]
val2 = l2[n % 4]
l3 = [1, 3, 9, 27]
val3 = l3[n % 4]
val4 = 0
if n % 2 == 0:
	val4 = 6
else:
	val4 = 4
if n == 0:
	print(4)
else:
	print((1 + val2 + val3 + val4) % 5)


def mp(a, n):
	res = 1
	while n:
		if n & 1:
			res = res * a % 5
		a = a * a % 5
		n >>= 1
	return res
n = int(input())
n &= 3
print((mp(2, n) + 1 + mp(3, n) + mp(4, n)) % 5)


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


n = int(input())
n = n % 4
if n == 1:
	print((2 + 3 + 4 + 1) % 5)
if n == 2:
	print((1 + 4 + 9 + 6) % 5)
if n == 3:
	print((7 + 4 + 8 + 1) % 5)
if n == 0:
	print((1 + 6 + 1 + 6) % 5)


s = input()
if len(s) >= 2:
	p = s[-2] + s[-1]
	x = int(p)
	y = 1 + 2 ** x + 3 ** x + 4 ** x
	print(y % 5)
else:
	x = int(s)
	y = 1 + 2 ** x + 3 ** x + 4 ** x
	print(y % 5)


import math, sys, re, itertools, pprint
(rs, ri, rai) = (input, lambda : int(input()), lambda : list(map(int, input().split())))
s = rs()
if len(s) > 10:
	x = int(s[-1]) + 10 * int(s[-2])
	if x % 4 == 0:
		print(4)
	else:
		print(0)
else:
	x = int(s)
	if x % 4 == 0:
		print(4)
	else:
		print(0)


n = int(input())
s = 0
if n % 4 == 0:
	s += 4
elif n % 4 == 1:
	s += 0
elif n % 4 == 2:
	s += 0
elif n % 4 == 3:
	s += 0
print(s)


import sys
input = sys.stdin.readline

def ceil(x):
	if x != int(x):
		x = int(x) + 1
	return x

def factorial(x, m):
	val = 1
	while x > 0:
		val = val * x % m
		x -= 1
	return val

def fact(x):
	val = 1
	while x > 0:
		val *= x
		x -= 1
	return val

def swaparr(arr, a, b):
	temp = arr[a]
	arr[a] = arr[b]
	arr[b] = temp

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

def nCr(n, k):
	if k > n - k:
		k = n - k
	res = 1
	for i in range(k):
		res = res * (n - i)
		res = res / (i + 1)
	return int(res)

def upper_bound(a, x, lo=0, hi=None):
	if hi == None:
		hi = len(a)
	while lo < hi:
		mid = (lo + hi) // 2
		if a[mid] < x:
			lo = mid + 1
		else:
			hi = mid
	return lo

def primefs(n):
	primes = {}
	while n % 2 == 0 and n > 0:
		primes[2] = primes.get(2, 0) + 1
		n = n // 2
	for i in range(3, int(n ** 0.5) + 2, 2):
		while n % i == 0 and n > 0:
			primes[i] = primes.get(i, 0) + 1
			n = n // i
	if n > 2:
		primes[n] = primes.get(n, 0) + 1
	return primes

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

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

def find(x, link):
	p = x
	while p != link[p]:
		p = link[p]
	while x != p:
		nex = link[x]
		link[x] = p
		x = nex
	return p

def union(x, y, link, size):
	x = find(x, link)
	y = find(y, link)
	if size[x] < size[y]:
		(x, y) = swap(x, y)
	if x != y:
		size[x] += size[y]
		link[y] = x

def sieve(n):
	prime = [True for i in range(n + 1)]
	(prime[0], prime[1]) = (False, False)
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime
MAXN = int(100000.0 + 5)

def spf_sieve():
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(4, MAXN, 2):
		spf[i] = 2
	for i in range(3, ceil(MAXN ** 0.5), 2):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i

def factoriazation(x):
	ret = {}
	while x != 1:
		ret[spf[x]] = ret.get(spf[x], 0) + 1
		x = x // spf[x]
	return ret

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

def float_array():
	return list(map(float, input().strip().split()))

def str_array():
	return input().strip().split()
MOD = int(1000000000.0) + 7
CMOD = 998244353
INF = float('inf')
NINF = -float('inf')
from itertools import permutations
import math
from bisect import bisect_left

def solve():
	n = int(input())
	print([4, 0][min(n % 4, 1)])
for _ in range(1):
	solve()


import math
s = input()
if s == '0':
	print(4)
	exit()
if len(s) == 1:
	k = int(s[-1:])
else:
	k = int(s[-2:])
sum = 0
if k % 4 == 0:
	sum += 6
else:
	sum += math.pow(2, k % 4)
if k % 4 == 0:
	sum += 1
else:
	t = math.pow(3, k % 4) % 10
	sum += t
if k % 2 == 0:
	sum += 6
else:
	sum += 4
sum += 1
print(int(sum % 5))


n = int(input())
print(sum((pow(i + 1, n, 5) for i in range(4))) % 5)


import sys
import math
n = sys.stdin.readline()
l = len(n)
k = 0
for i in range(l - 1):
	if k < 4 and i != l - 2:
		k += int(n[i]) * 10
	else:
		k += int(n[i])
		if k % 4 == 0:
			k = 0
		else:
			k = int(k % 4) * 10
if int(k / 10) == 0:
	print(4)
else:
	print(0)


n = int(input())
print([(2 ** (n % 4 + 1) + 2) % 5, 0][n % 2])


import sys
n = int(sys.stdin.readline())
print((1 + pow(2, n, 5) + pow(3, n, 5) + pow(4, n, 5)) % 5)


n = int(input())
np = n % 4
result = (1 + 2 ** np + 3 ** np + 4 ** np) % 5
print(result)


a = int(input())
ans = 1
if a % 4 == 0:
	e = 1
elif (a - 1) % 4 == 0:
	e = 3
elif (a - 2) % 4 == 0:
	e = 4
elif (a - 3) % 4 == 0:
	e = 2
if a % 4 == 0:
	e += 1
elif (a - 1) % 4 == 0:
	e += 2
elif (a - 2) % 4 == 0:
	e += 4
elif (a - 3) % 4 == 0:
	e += 3
if a % 2 == 0:
	e += 1
else:
	e += 4
ans = (e + 1) % 5
print(ans)


import sys
import collections
from collections import Counter
import itertools
import math
import timeit

def sieve(n):
	if n < 2:
		return list()
	prime = [True for _ in range(n + 1)]
	p = 3
	while p * p <= n:
		if prime[p]:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 2
	r = [2]
	for p in range(3, n + 1, 2):
		if prime[p]:
			r.append(p)
	return r

def divs(n, start=1):
	divisors = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				divisors.append(i)
			else:
				divisors.extend([i, n // i])
	return divisors

def divn(n, primes):
	divs_number = 1
	for i in primes:
		if n == 1:
			return divs_number
		t = 1
		while n % i == 0:
			t += 1
			n //= i
		divs_number *= t

def flin(d, x, default=-1):
	left = right = -1
	for i in range(len(d)):
		if d[i] == x:
			if left == -1:
				left = i
			right = i
	if left == -1:
		return (default, default)
	else:
		return (left, right)

def ceil(n, k):
	return n // k + (n % k != 0)

def ii():
	return int(input())

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

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

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

def prr(a, sep=' '):
	print(sep.join(map(str, a)))

def dd():
	return collections.defaultdict(int)

def ddl():
	return collections.defaultdict(list)
n = ii()
r = 0
for i in range(1, 5):
	t = [i ** j % 5 for j in range(0, 5)]
	r += t[n % 4]
print(r % 5)


twos = {0: 1, 1: 2, 2: 4, 3: 3}
fours = {0: 1, 1: 4}
threes = {0: 1, 1: 3, 2: 4, 3: 2}
n = int(input())
n1 = n % 4
n2 = n % 2
print((1 + twos[n1] + threes[n1] + fours[n2]) % 5)


lst = list(map(str, input().split()))
str = lst[0]
last = int(str[-2:])
if last % 4 != 0:
	print(0)
else:
	print(4)


x = int(input())
if x == 0:
	print(4)
	exit()
m4 = (x - 1) % 4
m2 = (x - 1) % 2
print((1 + [2, 4, 3, 1][m4] + [3, 4, 2, 1][m4] + [4, 1][m2]) % 5)


while True:
	try:
		x = int(input())
		if x % 4 == 0:
			print('4')
		if x % 4 != 0:
			print('0')
	except:
		break


import sys
input = sys.stdin.readline
n = input()
ans = [4, 0, 0, 0]
if len(n) < 2:
	n = int(n)
else:
	n = int(n[-3:])
print(ans[n % 4])


n = int(input())
if n == 0:
	print(4)
else:
	n = n % 4
	t = 1
	a = [2, 4, 8, 6]
	t += a[n - 1]
	a = [3, 9, 7, 1]
	t += a[n - 1]
	a = [4, 6]
	t += a[n % 2 - 1]
	print(t % 10)


R = lambda : map(int, input().split())
n = int(input())
if n % 4 == 0:
	print('4')
else:
	print('0')


cnt = lambda s, x: s.count(x)
ii = lambda : int(input())
si = lambda : input()
f = lambda : map(int, input().split())
il = lambda : list(map(int, input().split()))
dgl = lambda : list(map(int, input()))
n = ii()
if n == 0:
	print(4)
else:
	l = '0004'
	print(l[n % 4 - 1] if n % 4 != 0 else l[3])


n = int(input())
r = n % 4
if r == 0 or r == 4:
	print(4)
else:
	print(0)


N1 = [1, 1, 1, 1]
N2 = [2, 4, 8, 6]
N3 = [3, 9, 7, 1]
N4 = [4, 6, 4, 6]
a = int(input())
if a == 0:
	print(4)
else:
	a = a - 1
	id = a % 4
	print((N1[id] + N2[id] + N3[id] + N4[id]) % 5)


string = input()
string = '0' + string
toCheck = int(string[-2] + string[-1]) % 4
print((1 ** toCheck + 2 ** toCheck + 3 ** toCheck + 4 ** toCheck) % 5)


from sys import stdin, stdout
input = stdin.readline
ans = '4000'
n = input()[:-1]
if len(n) < 3:
	stdout.write(ans[int(n) % 4])
else:
	stdout.write(ans[int(n[-3:]) % 4])


n = int(input())
r = n % 4
l = [1, 2, 4, 3]
l1 = [1, 3, 4, 2]
l3 = [1, 4]
print((1 + l[r] + l1[r] + l3[n % 2]) % 5)


x = input()
print(0 if int(x[-min(2, len(x)):]) % 4 else 4)


def STR():
	return list(input())

def INT():
	return int(input())

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

def MAP2():
	return map(float, input().split())

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

def STRING():
	return input()
import string
import sys
from heapq import heappop, heappush
from bisect import *
from collections import deque, Counter
from math import *
from itertools import permutations, accumulate
dx = [-1, 1, 0, 0]
dy = [0, 0, 1, -1]
n = INT()
if n % 4 == 0:
	print(4)
else:
	print(0)


n = int(input())
r2 = n % 4
r3 = r2
r4 = n % 2
v = (1 + 2 ** r2 + 3 ** r3 + 4 ** r4) % 5
print(v)


a = input()
if len(a) > 1:
	a = a[-2:]
a = int(a)
if a % 4 == 0:
	print('4')
else:
	print('0')


from sys import stdin, stdout
import math
from itertools import permutations, combinations
from collections import defaultdict
from bisect import bisect_left
mod = 1000000007

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

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

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

def printIn(ob):
	return stdout.write(str(ob) + '\n')

def powerLL(n, p):
	result = 1
	while p:
		if p & 1:
			result = result * n % mod
		p = int(p / 2)
		n = n * n % mod
	return result
import sys

def myCode():
	n = I()
	ans = 1 + 2 ** (n % 4) + 3 ** (n % 4) + 4 ** (n % 2)
	ans = ans % 5
	print(ans)

def main():
	myCode()
main()


n = int(input())
one = 1
two = {1: 2, 2: 4, 3: 3, 0: 1}
three = {1: 3, 2: 4, 3: 2, 0: 1}
four = {1: 4, 0: 1}
twothreetemp = n % 4
fourtemp = n % 2
print((one + two[twothreetemp] + three[twothreetemp] + four[fourtemp]) % 5)


import sys
import math
import array
n = sys.stdin.readline()
n = int(n)
th = pow(3, n, 5)
tw = pow(2, n, 5)
fo = pow(4, n, 5)
sm = 1 + tw + th + fo
sm %= 5
print(sm)


n = input()
if n == 0:
	print(4)
else:
	last3 = int(n[-3:])
	total = 1
	e = last3 % 4
	if e == 0:
		e = 4
	total += 2 ** e % 10
	total += 3 ** e % 10
	last = int(n[-1:])
	e = last % 2
	if e == 0:
		e = 2
	total += 4 ** e % 10
	print(total % 5)


import math as m

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

def mmap():
	return map(int, input().split())
n = int(input())
tot = m.pow(1, n % 4) + m.pow(2, n % 4) + m.pow(3, n % 4) + m.pow(4, n % 4)
print(int(tot % 5))


n = int(input())
n = n % 20
if n % 4 == 0:
	print(4)
else:
	print(0)


n = int(input()) & 3
t = 0
for i in range(1, 5):
	t += i ** n
print(t % 5)


s = input()
mod = 0
for i in range(len(s)):
	curr = ord(s[i]) - ord('0')
	mod = (mod * 10 + curr) % 4
if mod == 0:
	print(4)
elif mod == 1:
	print((1 + 2 + 3 + 4) % 5)
elif mod == 2:
	print((1 + 2 ** 2 + 3 ** 2 + 4 ** 2) % 5)
elif mod == 3:
	print((1 + 2 ** 3 + 3 ** 3 + 4 ** 3) % 5)


line_2 = [2, 4, 8, 6]
line_3 = [3, 9, 7, 1]
line_4 = [4, 6, 4, 6]
n = int(input())
if n == 0:
	print(4)
else:
	n = (n - 1) % 4
	print((1 + line_2[n] + line_3[n] + line_4[n]) % 5)


n = int(input())
s = 0
for i in range(1, 5):
	s += pow(i, n, 5)
print(s % 5)


n = int(input())
ans = 4 if n % 4 == 0 else 0
print(ans)


n = int(input())
if n == 0:
	print(4)
else:
	ost = 1
	if n % 4 == 1:
		ost += 5
	elif n % 4 == 2:
		ost += 8
	elif n % 4 == 3:
		ost += 5
	elif n % 4 == 0:
		ost += 2
	if n % 2 == 0:
		ost += 1
	else:
		ost += 4
	print(ost % 5)


N = int(input())
N_mod = N % 4
X = 1 ** N_mod + 2 ** N_mod + 3 ** N_mod + 4 ** N_mod
print(X % 5)


def degree(s):
	t = '00' + s.rstrip()
	x = int(t[-2:])
	if x % 4 == 0:
		return '4'
	return '0'
n = int(input())
print(degree(str(n)))


N = int(input())
d = [1, 1, 1, 1]
if N % 4 == 0:
	print(d[0] + d[1] + d[2] + d[3])
elif N % 4 == 1:
	print(0)
elif N % 4 == 2:
	print(0)
else:
	print(0)


arr = []
arr = input()
length = len(arr)
t = int(arr[length - 2]) * 10 + int(arr[length - 1])
if t % 4 is 0:
	print('4')
else:
	print('0')


n = list(input())
if len(n) == 1 and n[-1] in '048':
	print('4')
elif len(n) == 1:
	print('0')
elif int(n[-2] + n[-1]) % 4 == 0:
	print('4')
else:
	print('0')


a = input()
b = len(a)
r = int(a)
if b < 2:
	k = r % 4
	if k == 0:
		print(4)
	elif k == 1:
		print(0)
	elif k == 2:
		print(0)
	else:
		print(0)
else:
	c = int(a[-2:])
	i = c % 4
	if i == 0:
		print(4)
	elif i == 1:
		print(0)
	elif i == 2:
		print(0)
	else:
		print(0)


n = int(input())
n = n % 100
if n % 4 == 0:
	print('4')
else:
	print('0')


s = input()
a = s[len(s) - 2:]
b = int(a)
if b % 4 == 0:
	print(4)
else:
	print(0)


n = int(input().strip())
if n == 0:
	print(4)
else:
	k = 0
	if n % 4 == 0:
		k += 14
	elif n % 4 == 1:
		k += 10
	elif n % 4 == 2:
		k += 20
	else:
		k += 20
	print(k % 5)


n = input()
sum = 0
length = len(n)
if length > 1:
	sum = sum + ord(n[length - 1])
	sum = sum + ord(n[length - 2]) * 10
else:
	sum = sum + ord(n[length - 1])
if sum % 4 == 0:
	print('4')
else:
	print('0')


import sys
from math import log

def exp_rapida(base, exp, modulus):
	res = 1
	base = base % modulus
	while exp > 0:
		if exp % 2:
			res = res * base % modulus
		exp = exp >> 1
		base = base * base % modulus
	return res
for line in sys.stdin:
	n = int(line.strip())
	soma = 1
	x = exp_rapida(2, n % 4, 5)
	soma += x % 5
	soma += x ** 2 % 5
	soma += exp_rapida(3, n % 4, 5)
	soma %= 5
	print(soma)


import sys
from math import *

def solve(k):
	res = 0
	for c in k:
		res = (res * 10 + int(c)) % 4
	f = lambda x: 2 ** x + 3 ** x + 4 ** x + 1
	return f(res) % 5

def main():
	print(solve(str(input())))
main()


n = input()
if len(n) > 1:
	m = n[-2] + n[-1]
	m = int(m)
	t = m % 4
	s = 1 ** t + 2 ** t + 3 ** t + 4 ** t
	su = s % 5
	print(su)
else:
	n = int(n)
	t = n % 4
	s = 1 ** t + 2 ** t + 3 ** t + 4 ** t
	su = s % 5
	print(su)


def rint():
	return int(input())

def rints():
	return list(map(int, input().split()))
n = rint()
print((1 + pow(2, n, 5) + pow(3, n, 5) + pow(4, n, 5)) % 5)


s = ''
s = input()
length = len(s)
temp = int(s[length - 2]) * 10 + int(s[length - 1])
if temp % 4 == 0:
	print('4')
else:
	print('0')


s = input()
if int(s[len(s) - 2:len(s)]) % 4 == 0:
	print(4)
else:
	print(0)


n = int(input())
if n % 4 == 0:
	print(4)
elif n == 0:
	print(4)
else:
	print(0)


def main():
	n = int(input()[-2:])
	result = (1 + 2 ** ((n - 1) % 4 + 1) + 3 ** ((n - 1) % 4 + 1) + 4 ** ((n - 1) % 2 + 1)) % 5
	print(result)
main()


def exp_mod(base, exponent, modulus):
	result = 1
	base = base % modulus
	while exponent > 0:
		if exponent % 2 == 1:
			result = result * base % modulus
		exponent = exponent >> 1
		base = pow(base, 2) % modulus
	return result
exponent = int(input())
exponent = exponent % 4
result = pow(1, exponent) + pow(2, exponent) + pow(3, exponent) + pow(4, exponent)
result = result % 5
print(result)


n = int(input())
if n % 2:
	print(0)
else:
	a = [1, 2, 4, 3]
	b = [1, 3, 4, 2]
	c = [1, -1]
	print((1 + a[n % 4] + b[n % 4] + c[n % 2]) % 5)


n = int(input())
sum = 1 ** (n % 4) + 2 ** (n % 4) + 3 ** (n % 4) + 4 ** (n % 4)
print(sum % 5)


n = int(input())
total = 1
k = n % 4
if k == 0:
	total = total + 3
else:
	total = total + 9
print(total % 5)


n = list(map(int, input()))
if len(n) >= 2:
	temp = 10 * n[len(n) - 2] + n[len(n) - 1]
else:
	temp = n[0]
ans = 4 if temp % 4 == 0 else 0
print(ans)


def main():
	n = int(input())
	if n % 4 == 0 or n == 0:
		print(4)
	else:
		print(0)
main()


n = int(input())
if n == 0:
	print(4)
	exit()
print((1 + pow(2, n, 5) + pow(3, n, 5) + pow(4, n, 5) + pow(5, n, 5)) % 5)


n = int(input())
result = (pow(1, n, 5) + pow(2, n, 5) + pow(3, n, 5) + pow(4, n, 5)) % 5
print(result)


n = int(input())
myList = [4, 0, 0, 0]
print(myList[n % 4])


n = int(input(''))
mod = n % 4
ans = 1 ** mod + 2 ** mod + 3 ** mod + 4 ** mod
print(ans % 5)


ls = [[1], [1, 2, 4, 3], [1, 3, 4, 2], [1, 4]]
n = int(input())
ans = 0
for i in range(4):
	ans += ls[i][n % len(ls[i])]
print(ans % 5)


n = int(input())
total = 1
total = total + pow(2, n, 5) + pow(3, n, 5) + pow(4, n, 5)
total = total % 5
print(total)


n = int(input().strip())
ans = 0
for i in range(1, 5):
	ans += pow(i, n, 5)
print(ans % 5)


n = int(input())
j = 0
if n == 0:
	j = 4
else:
	j = j + 1
	m = n % 4
	if m == 1:
		j += 2
	elif m == 2:
		j += 4
	elif m == 3:
		j += 8
	elif m == 0:
		j += 6
	m = n % 4
	if m == 1:
		j += 3
	elif m == 2:
		j += 9
	elif m == 3:
		j += 7
	elif m == 0:
		j += 1
	if n % 2 == 1:
		j += 4
	else:
		j += 6
	j = j % 5
print(j)


n = int(input())
if n == 0:
	print(4)
	exit()
tt = [0, 3, 0, 2]
f = [4, 6]
print((1 + tt[(n - 1) % 4] + f[(n - 1) % 2]) % 5)


n = int(input())
a = n % 4
if a == 1:
	print('0')
elif a == 2:
	print('0')
elif a == 3:
	print('0')
elif a == 0:
	print('4')


n = int(input())
if n % 2:
	print(0)
else:
	Hash = {1: 2, 2: 4, 3: 3, 4: 1}
	print((Hash[(n + 1) % 4] + 2) % 5)


m = input()
n = int(m[len(m) - 2:])
n = n % 4
sol = 0
x = pow(2, n, 5)
sol = (sol % 5 + x % 5) % 5
x = pow(3, n, 5)
sol = (sol % 5 + x % 5) % 5
x = pow(4, n, 5)
sol = (sol % 5 + x % 5) % 5
sol = (sol % 5 + 1) % 5
print(sol)


print(eval('(1+(1, 2, 4, 3)[{0}%4]+(1, 3, 4, 2)[{0}%4]+(1, 4)[{0}%2])%5'.format(int(input()) % 4)))


def f(n, till):
	i = 1
	while i < till:
		i += 1
	return
two = {1: 2, 2: 4, 3: 3, 0: 1}
three = {1: 3, 2: 4, 3: 2, 0: 1}
four = {1: 4, 0: 1}
s = input()
s = int(s[-2:])
sumx = 1 + two[s % 4] + three[s % 4] + four[s % 2]
print(sumx % 5)


n = int(input())
m4 = n % 4
answ = 1 + 2 ** m4 + 3 ** m4 + 4 ** m4
print(answ % 5)


n = int(input())
two = 2 ** ((n - 1) % 4 + 1)
three = 3 ** ((n - 1) % 4 + 1)
four = 4 ** ((n - 1) % 2 + 1)
print((1 + two + three + four) % 5)


import sys
import string
from collections import Counter, defaultdict
from math import fsum, sqrt, gcd, ceil, factorial
from itertools import combinations, permutations
flush = lambda : sys.stdout.flush
comb = lambda x, y: factorial(x) // factorial(y) // factorial(x - y)
ip = lambda : input()
ii = lambda : int(input())
r = lambda : map(int, input().split())
rr = lambda : list(r())
n = ii()
n -= 1
arr = {}
arr[2] = [2, 4, 8, 6]
arr[3] = [3, 9, 7, 1]
arr[4] = [4, 6]
x = arr[2][n % 4]
x += arr[3][n % 4]
x += arr[4][n % 2] + 1
print(x % 5)


n = int(input())
r = n % 4
two = [6, 2, 4, 8]
three = [1, 3, 9, 7]
four = [6, 4, 6, 4]
print((1 + two[r] + three[r] + four[r]) % 5)


number = input()
if len(number) >= 2:
	end = int(number[-2:]) - 1
	vals2 = [2, 4, 3, 1]
	vals3 = [3, 4, 2, 1]
	vals4 = [4, 1]
	val = (1 + vals2[end % 4] + vals3[end % 4] + vals4[end % 2]) % 5
	print(val)
else:
	print((1 ** int(number) + 2 ** int(number) + 3 ** int(number) + 4 ** int(number)) % 5)


def patterns(i):
	add = 0
	thedict = {2: [1, 2, 4, 3], 3: [1, 3, 4, 2], 4: [1, 4, 1, 4]}
	for j in thedict.keys():
		add += thedict[j][i % 4]
	return add % 5
a = int(input())
z = 1 + patterns(a)
print(z % 5)


a = int(input())
if a % 4 == 1 or a % 4 == 2 or a % 4 == 3:
	print(0)
else:
	print(4)


from math import *
from sys import *
from decimal import *
s = '00' + input()
x = int(s[-2] + s[-1])
if x % 4:
	print(0)
else:
	print(4)


a = int(input()[-2:])
s = [pow(x, a) for x in range(1, 5)]
print(sum(s) % 5)


n = input()
if n == '0':
	print(4)
else:
	final = 1
	if int(n[-1]) % 2 == 0:
		final += 6
	else:
		final += 4
	m = int(n[-2:])
	if m % 4 == 0:
		final += 7
	elif m % 2 == 0:
		final += 3
	else:
		final += 5
	print(final % 5)


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


n = int(input())
l1 = [1, 1, 1, 1]
l2 = [1, 2, 4, 3]
l3 = [1, 3, 4, 2]
l4 = [1, 4, 1, 4]
val = n % 4
ans = l1[val] + l2[val] + l3[val] + l4[val]
ans %= 5
print(ans)


n = int(input())
if n % 4 == 0:
	result = 4
else:
	result = 0
print(result)


n = int(input())
s = 1
if n % 4 == 0:
	s += 3
else:
	s += 9
print(s % 5)


inp_str = input()
new_str = ''
if len(inp_str) >= 2:
	new_str += inp_str[-2] + inp_str[-1]
	if int(new_str) % 4 == 0:
		print(4)
	else:
		print(0)
elif int(inp_str) % 4 == 0:
	print(4)
else:
	print(0)


n = int(input())
result = 1
if n % 2 == 0:
	if n % 4 == 0:
		result += 3
	else:
		result += 9
elif (n + 1) % 4 == 0:
	result += 9
else:
	result += 9
result %= 5
print(result)


a2 = [1, 2, 4, 3]
a3 = [1, 3, 4, 2]
a4 = [1, 4, 1, 4]
x = int(input())
x = x % 4
print((1 + a2[x] + a3[x] + a4[x]) % 5)


import sys

def FastModularExponentiation(b, e, m):
	res = 1
	b = b % m
	while e > 0:
		if e & 1 == 1:
			res = res * b % m
		e = e >> 1
		b = b * b % m
	return res
m = int(sys.stdin.read())
n = (1 + FastModularExponentiation(2, m % 4, 5) + FastModularExponentiation(3, m % 4, 5) + FastModularExponentiation(4, m % 4, 5)) % 5
print(n)


n = int(input())
m = n % 4
ans = (1 + 2 ** m + 3 ** m + 4 ** m) % 5
print(ans)


import math
s = int(input())
n = s % 4
x1 = 1
x2 = math.pow(2, n)
x3 = math.pow(3, n)
x4 = math.pow(4, n)
z = x1 + x2 + x3 + x4
v = str(int(z))
c = v[-1]
for i in range(0, 9):
	if i == int(c):
		print(i % 5)
		break


n = input()
if len(n) < 5:
	if int(n) % 4 == 0:
		print(4)
	else:
		print(0)
elif int(n[-2:]) % 4 == 0:
	print(4)
else:
	print(0)


fast = lambda : stdin.readline().strip()
zzz = lambda : [int(i) for i in fast().split()]
(z, zz) = (input, lambda : list(map(int, z().split())))
(szz, graph, mod, szzz) = (lambda : sorted(zz()), {}, 10 ** 9 + 7, lambda : sorted(zzz()))
from re import *
from sys import *
from math import *
from heapq import *
from queue import *
from bisect import *
from string import *
from itertools import *
from collections import *
from math import factorial as f
from bisect import bisect as bs
from bisect import bisect_left as bsl
from collections import Counter as cc
from itertools import accumulate as ac

def lcd(xnum1, xnum2):
	return xnum1 * xnum2 // gcd(xnum1, xnum2)

def output(answer):
	stdout.write(str(answer))
n = int(z())
if n % 4 == 0:
	print(4)
else:
	print(0)


from sys import stdin, stdout
import bisect

def st():
	return list(stdin.readline())

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

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

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

def pr(n):
	stdout.write(str(n) + '\n')

def soe(limit):
	l = [1] * (limit + 1)
	prime = []
	for i in range(2, limit + 1):
		if l[i]:
			for j in range(i * i, limit + 1, i):
				l[j] = 0
	for i in range(2, limit + 1):
		if l[i]:
			prime.append(i)
	return prime

def segsoe(low, high):
	limit = int(high ** 0.5) + 1
	prime = soe(limit)
	n = high - low + 1
	l = [0] * (n + 1)
	for i in range(len(prime)):
		lowlimit = low // prime[i] * prime[i]
		if lowlimit < low:
			lowlimit += prime[i]
		if lowlimit == prime[i]:
			lowlimit += prime[i]
		for j in range(lowlimit, high + 1, prime[i]):
			l[j - low] = 1
	for i in range(low, high + 1):
		if not l[i - low]:
			if i != 1:
				print(i)

def power(a, n):
	r = 1
	while n:
		if n & 1:
			r = r * a
			n = n - 1
		else:
			a = a * a
			n = n >> 1
	return r

def solve():
	n = inp()
	if n % 4:
		pr(0)
	else:
		pr(4)
solve()


def ras(n):
	if n % 2 == 0:
		if n % 4 == 0:
			return 4
		elif n % 4 == 1:
			return 1
		elif n % 4 == 2:
			return 0
		else:
			return 3
	else:
		return 0
n = int(input())
r = ras(n)
print(r)


print('40000'[int(input()[-2:]) % 4])


a = '0' + input()
a1 = [1, 1, 1, 1]
a2 = [1, 2, 4, 3]
a3 = [1, 3, 4, 2]
a4 = [1, 4, 1, 4]
t = (int(a[-2]) * 10 + int(a[-1])) % 4
print((a1[t] + a2[t] + a3[t] + a4[t]) % 5)


s = input()
a = int(s[max(0, len(s) - 2):len(s)])
print(4 * int(a % 4 == 0))


a = input()
if a.__len__() == 2 or a.__len__() == 1:
	if int(a) % 4 == 0:
		print(4)
		exit(0)
	else:
		print(0)
		exit(0)
b = a[a.__len__() - 2]
c = a[a.__len__() - 1]
if int(b + c) % 4 == 0:
	print(4)
else:
	print(0)
exit(0)


s = input()
if len(s) <= 2:
	if int(s) % 4 == 0:
		print(4)
	else:
		print(0)
else:
	ans = int(s[len(s) - 2]) * 10 + int(s[len(s) - 1])
	if ans % 4 == 0:
		print(4)
	else:
		print(0)


N = input()
X = 0
if len(N) > 2:
	X = int(N[-2:])
else:
	X = int(N)
if X % 4 == 0:
	print(4)
else:
	print(0)


s = input()
if len(s) >= 2:
	n = int(s[-2:])
else:
	n = int(s)
sum = 0
if n % 4 == 0:
	sum = 4
else:
	sum = 0
print(sum)


s = input()
ans = 1
temp = len(s)
if temp >= 2:
	temp2 = int(s[temp - 2:temp])
	if temp2 % 4 == 0:
		ans += 13
	else:
		ans += 2 ** (temp2 % 4)
		ans += 3 ** (temp2 % 4)
		ans += 4 ** (temp2 % 4)
else:
	ans += 2 ** int(s) + 3 ** int(s) + 4 ** int(s)
print(ans % 5)


n = int(input())
y = n % 4
print((1 + 2 ** y + 3 ** y + (-1) ** y) % 5)


n = int(input()) % 4
res = 1 + pow(2, n, 5) + pow(3, n, 5) + pow(4, n, 5)
print(res % 5)


a = int(input())
if a % 4 == 0:
	print('4\n')
else:
	print('0\n')


n = int(input())
k = n % 4
if k == 0:
	print(4)
else:
	print(0)


n = input()
idx = int(n) % 4
suma = 1 + 2 ** idx + 3 ** idx + 4 ** idx
suma = suma % 5
print(suma)


N = int(input())
rem = N % 4
res = 1 + 2 ** rem + 3 ** rem + 4 ** rem
print(res % 5)


n = input()
if len(n) <= 2:
	n = int(n)
	if n % 4 == 0:
		print(4)
	else:
		print(0)
else:
	x = n[-2] + n[-1]
	x = int(x)
	if x % 4 == 0:
		print(4)
	else:
		print(0)


print((int(input()) % 4 < 1) * 4)


n = input()
l = len(n)
if l == 1:
	i = int(n) % 4
else:
	i = (int(n[l - 2]) * 10 + int(n[l - 1])) % 4
if not i:
	print('4')
else:
	print((1 + 2 ** i + 3 ** i + 4 ** i) % 5)


str = input()
if len(str) > 1:
	t = int(str[len(str) - 2:len(str)])
else:
	t = int(str[len(str) - 1])
if not t % 4:
	print('4')
else:
	print('0')


n = input()
res = 1
num = 0
for i in n:
	num += int(i)
t = int(n[-2:]) % 4
res += 2 ** t + 3 ** t + 4 ** t
print(res % 5)


def fun():
	n = int(input())
	n = n % 4
	ans = (1 + pow(2, n)) % 5
	ans = (ans + pow(3, n)) % 5
	ans = (ans + pow(4, n)) % 5
	print(ans)
fun()


inp = input()
if len(inp) > 3:
	n = int(inp[-2] + inp[-1])
else:
	n = int(inp)
if n % 4 == 0:
	print(4, end='')
else:
	print(0, end='')


s = input()
if s == '4' or s == '8':
	print(4)
elif int(s[-2:]) % 4 == 0:
	print(4)
else:
	print(0)


s = input()
if len(s) == 1:
	n = int(s)
	ans = (1 + pow(2, n, 5) + pow(3, n, 5) + pow(4, n, 5)) % 5
else:
	a = s[-2]
	b = s[-1]
	num = 10 * int(a) + int(b)
	ans = (1 + pow(2, num, 5) + pow(3, num, 5) + pow(4, num, 5)) % 5
print(ans)


n = int(input())
x = pow(2, n, 5)
y = pow(3, n, 5)
z = pow(4, n, 5)
print((1 + x + y + z) % 5)