# def f(n, r):
# global s
# if r == 0:
# return 1
# s = s * (n - r + 1)
# f(n, r - 1)
#
#
# def g(n, r):
# global s
# if r == 0:
# return 1
# s = s // r
# g(n, r-1)
#
#
# s = 1
# n, r = map(int, input().split())
# f(n, r)
# g(n, r)
# print(s)
# import sys
# limit_number = 2000000
# sys.setrecursionlimit(limit_number)
# def f(n):
# global m
# if m[n-1] != 0:
# return m[n-1]
# if n == 1:
# m[0] = 1;
# return 1
# if n == 2:
# m[1] = 3
# return 3
# m[n-1] = f(n-1) + f(n-2) * 2
# return m[n-1] % 100007
#
#
# n = int(input())
# m = [0] * n
# print(f(n))
# n = int(input())
# d = list(map(int, input().split()))
# c = 0
# for i in range(n - 1):
# for j in range(i + 1, n):
# if (d[i] + d[j]) % 3 == 0:
# c = c + 1
# print(c)
# def dfs(i, j, s):
# global n
# global min
# if i == n:
# if min > s:
# min = s
# return 1
# s = s + d[i][j]
# if j != 0:
# dfs(i + 1, 0, s)
# if j != 1:
# dfs(i + 1, 1, s)
# if j != 2:
# dfs(i + 1, 2, s)
#
#
# n = int(input())
# d = [] * (n+1)
# for i in range(n):
# v = [0] * 4
# v = list(map(int, input().split()))
# d.append(v)
# min = 0
# for i in range(n):
# q = (d[i][0] if d[i][0] > d[i][1] else d[i][1]) if (d[i][0] if d[i][0] > d[i][1] else d[i][1]) > d[i][2] else d[i][2]
# min = min + q
#
# dfs(0, 0, 0)
# dfs(0, 1, 0)
# dfs(0, 2, 0)
# print(min)