Alice and Bob are decorating a Christmas Tree. 

Alice wants only $3$ types of ornaments to be used on the Christmas Tree: yellow, blue and red. They have $y$ yellow ornaments, $b$ blue ornaments and $r$ red ornaments.

In Bob's opinion, a Christmas Tree will be beautiful if:  the number of blue ornaments used is greater by exactly $1$ than the number of yellow ornaments, and  the number of red ornaments used is greater by exactly $1$ than the number of blue ornaments. 

That is, if they have $8$ yellow ornaments, $13$ blue ornaments and $9$ red ornaments, we can choose $4$ yellow, $5$ blue and $6$ red ornaments ($5=4+1$ and $6=5+1$).

Alice wants to choose as many ornaments as possible, but she also wants the Christmas Tree to be beautiful according to Bob's opinion.

In the example two paragraphs above, we would choose $7$ yellow, $8$ blue and $9$ red ornaments. If we do it, we will use $7+8+9=24$ ornaments. That is the maximum number.

Since Alice and Bob are busy with preparing food to the New Year's Eve, they are asking you to find out the maximum number of ornaments that can be used in their beautiful Christmas Tree! 

It is guaranteed that it is possible to choose at least $6$ ($1+2+3=6$) ornaments.


-----Input-----

The only line contains three integers $y$, $b$, $r$ ($1 \leq y \leq 100$, $2 \leq b \leq 100$, $3 \leq r \leq 100$) — the number of yellow, blue and red ornaments. 

It is guaranteed that it is possible to choose at least $6$ ($1+2+3=6$) ornaments.


-----Output-----

Print one number — the maximum number of ornaments that can be used. 


-----Examples-----
Input
8 13 9

Output
24
Input
13 3 6

Output
9


-----Note-----

In the first example, the answer is $7+8+9=24$.

In the second example, the answer is $2+3+4=9$.

Source: codeforces | Difficulty: EASY
Tags: Mathematics

Implementation

Complete search


Solutions:
(A, B, C) = map(int, input().split())
if B >= C:
	B = C - 1
if A < B - 1:
	B = A + 1
print(3 * B)


(y, b, r) = map(int, input().split())
x = min(y + 2, b + 1, r)
print(x * 3 - 3)


(y, b, r) = map(int, input().split())
y = y + 1
r -= 1
print(3 * min(y, b, r))


a = []
a = input().split()
for i in range(3):
	a[i] = int(a[i])
for i in range(a[0], 0, -1):
	if i + 1 <= a[1] and i + 2 <= a[2]:
		print(i + i + i + 3)
		break


(y, b, r) = input().split()
y = int(y)
b = int(b)
r = int(r)
m = min(y, b, r)
if m == y:
	if m + 1 <= b and m + 2 <= r:
		print(3 * m + 3)
	else:
		while m + 1 > b or m + 2 > r:
			m -= 1
		print(3 * m + 3)
elif m == b:
	if m - 1 <= y and m + 1 <= r:
		print(3 * m)
	else:
		while m - 1 > y or m + 1 > r:
			m -= 1
		print(3 * m)
elif m - 1 <= b and m - 2 <= y:
	print(3 * m - 3)
else:
	while m - 1 > b or m - 2 > y:
		m -= 1
	print(3 * m - 3)


(a, b, c) = input().strip().split(' ')
a = int(a)
b = int(b)
c = int(c)
print(min(a, b - 1, c - 2) * 3 + 3)


import sys
pin = sys.stdin.readline
pout = sys.stdout.write
total = list(map(int, pin().split()))
print(min(total[0] + 2, min(total[1] + 1, total[2])) * 3 - 3)


(a, b, c) = [int(x) for x in input().split()]
mi = min(a, b, c)
if mi == c:
	print(c + (c - 1) + (c - 2))
elif mi == b:
	print(b - 1 + b + (b + 1))
elif mi == c - 1:
	print(a + (a - 1) + (a + 1))
else:
	print(a + (a + 1) + (a + 2))


(y, b, r) = map(int, input().split())
print(min(y + 2 + y + 1 + y, b - 1 + b + b + 1, r - 2 + r - 1 + r))


from bisect import bisect_right as br
from bisect import bisect_left as bl
from collections import defaultdict
from itertools import combinations
import functools
import sys
import math
MAX = sys.maxsize
MAXN = 10 ** 6 + 10
MOD = 10 ** 9 + 7

def isprime(n):
	n = abs(int(n))
	if n < 2:
		return False
	if n == 2:
		return True
	if not n & 1:
		return False
	for x in range(3, int(n ** 0.5) + 1, 2):
		if n % x == 0:
			return False
	return True

def mhd(a, b, x, y):
	return abs(a - x) + abs(b - y)

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

def charIN():
	return sys.stdin.readline().strip().split()
t = [0] * 1000010

def create(a, n):
	global t
	for i in range(n, 2 * n):
		t[i] = a[i - n]
	for i in range(n - 1, 0, -1):
		t[i] = t[2 * i] + t[2 * i + 1]

def ncr(n, k):
	res = 1
	c = [0] * (k + 1)
	c[0] = 1
	for i in range(1, n + 1):
		for j in range(min(i, k), 0, -1):
			c[j] = (c[j] + c[j - 1]) % MOD
	return c[k]
(y, b, r) = numIN()
for i in range(y, 0, -1):
	if b >= i + 1 and r >= i + 2:
		print(i + i + 1 + i + 2)
		exit(0)


from sys import stdin
(y, b, r) = map(int, stdin.readline().split())
minC = min(y, b, r)
sum = 6
y -= 1
r -= 3
b -= 2
while y > 0 and b > 0 and (r > 0):
	sum += 3
	y -= 1
	b -= 1
	r -= 1
print(sum)


(y, b, r) = map(int, input().strip().split(' '))
mi = min(y, b, r)
yy = 1
bb = 2
rr = 3
for i in range(mi):
	if yy + 1 <= y and bb + 1 <= b and (rr + 1 <= r):
		yy = yy + 1
		bb = bb + 1
		rr = rr + 1
	else:
		print(yy + bb + rr)
		break


(y, b, r) = map(int, input().strip().split())
for i in range(y, 0, -1):
	if b - i >= 1 and r - i >= 2:
		ans = 3 * i + 3
		break
print(ans)


(y, b, r) = [int(i) for i in input().split()]
m = min(y, b, r)
res = 0
if r == m:
	res = 3 * r - 3
elif b == m:
	res = 3 * b
elif r > b or r - y >= 2:
	res = 3 * y + 3
else:
	res = 3 * (y - 1) + 3
print(res)


(y, b, r) = list(map(int, input().split()))
for i in range(101, -1, -1):
	if i <= y and i + 1 <= b and (i + 2 <= r):
		print(3 * i + 3)
		exit(0)
print(0)


(y, b, r) = map(int, input().split())
L = [y, b - 1, r - 2].index(min([y, b - 1, r - 2]))
if L == 0:
	print(3 * y + 3)
elif L == 1:
	print(3 * b)
else:
	print(3 * r - 3)


(y, b, r) = map(int, input().split())
k = 0
for i in range(1000):
	if i <= y and i + 1 <= b and (i + 2 <= r):
		k = i
print(3 * k + 3)


import math
import sys
DEBUG = False

def inp():
	return sys.stdin.readline().rstrip()

def dprint(*value, sep=' ', end='\n'):
	if DEBUG:
		print(*value, sep=sep, end=end)

def main():
	(Y, B, R) = [int(e) for e in inp().split()]
	best = 0
	for r in range(3, 101):
		b = r - 1
		y = b - 1
		if y <= Y and b <= B and (r <= R):
			best = y + b + r
	print(best)
main()


(y, b, r) = map(int, input().split())
while True:
	if y + 1 <= b and y + 2 <= r:
		print(3 * y + 3)
		exit()
	y -= 1


(y, b, r) = map(int, input().split())
if y < b - 1:
	y = y
else:
	y = b - 1
if y < r - 2:
	y = y
else:
	y = r - 2
print(3 * y + 3)


(y, b, r) = list(map(int, input().split()))
minNum = min(y, b, r)
if y == minNum:
	if b == minNum:
		if r == minNum:
			y = y - 2
		else:
			y = y - 1
	elif r == minNum:
		y = y - 2
	elif r == minNum + 1:
		y = y - 1
elif b == minNum:
	if r == minNum:
		y = b - 2
	else:
		y = b - 1
else:
	y = r - 2
print(3 * y + 3)


(y, b, r) = [int(x) for x in input().split()]
y += 1
r -= 1
m = min(y, b, r)
print(3 * m)


R = lambda : map(int, input().split())
(y, b, r) = R()
t = min(y + 2, b + 1, r)
if t == y + 2:
	print(3 * y + 3)
elif t == b + 1:
	print(3 * b)
else:
	print(3 * r - 3)


(y, b, r) = map(int, input().split())
m = 0
for i in range(y + 1):
	for j in range(b + 1):
		for k in range(r + 1):
			if k == j + 1 == i + 2 and k + j + i > m:
				m = k + j + i
print(m)


a = list(map(int, input().split()))
a = a[::-1]
mi = min(a)
x = a.index(mi)
if x == 0:
	print(mi + mi - 1 + mi - 2)
elif x == 1:
	print(mi + 1 + mi + mi - 1)
elif x == 2:
	if a[0] >= mi + 2:
		print(mi + 2 + mi + 1 + mi)
	elif a[0] == mi + 1:
		print(mi + 1 + mi + mi - 1)


import math
(y, b, r) = input().split()
y = int(y)
b = int(b)
r = int(r)
if r - 1 <= b and r - 2 <= y:
	print(3 * r - 3)
elif b - 1 <= y and b + 1 <= r:
	print(3 * b)
else:
	print(3 * y + 3)


a = input().split()
y = int(a[0])
b = int(a[1]) - 1
r = int(a[2]) - 2
x = min(y, b, r)
print(3 * x + 3)


def answer():
	a = [int(x) for x in input().split()]
	i = 0
	while i <= a[0] and i + 1 <= a[1] and (i + 2 <= a[2]):
		i += 1
	return i * 3
print(answer())


ybr = list(map(int, input().split()))
minimum = min(ybr[0], ybr[1] - 1, ybr[2] - 2)
print(minimum * 3 + 3)


import re

def numOfOrnaments():
	roughBeginning = re.findall('\\d+', input(''))
	beginning = []
	for element in roughBeginning:
		beginning.append(int(element))
	yellow = beginning[0]
	blue = beginning[1]
	red = beginning[2]
	aggregateArray = [yellow, blue - 1, red - 2]
	baseNumber = 0
	for index in range(0, len(aggregateArray)):
		if aggregateArray[baseNumber] > aggregateArray[index]:
			baseNumber = index
	if 0 == baseNumber:
		print(3 * yellow + 3)
	elif 1 == baseNumber:
		print(3 * blue)
	elif 2 == baseNumber:
		print(3 * red - 3)
numOfOrnaments()


ybr = list(map(int, input().strip().split()))
print(6 + 3 * min(ybr[0] - 1, ybr[1] - 2, ybr[2] - 3))


s = list(map(int, input().split(' ')))
y = s[0]
b = s[1]
r = s[2]
total = 0
l = min(s)
if y == l:
	if b == y and r == y:
		total = 3 * l - 3
	elif b == y and r != y:
		total = 3 * l
	elif b != y and r == y + 1:
		total = 3 * l
	elif b != y and r != y:
		total = 3 * l + 3
	elif b != y and r == y:
		total = 3 * l - 3
elif b == l:
	if b == y and b == r:
		total = 3 * l - 3
	elif b == y and b != r:
		total = 3 * l
	elif b != y and b == r:
		total = 3 * l - 3
	elif b != y and r >= b + 1:
		total = 3 * l
elif r == l:
	total = 3 * l - 3
print(total)


(a, b, c) = map(int, input().split())
while not a + 2 == b + 1 == c:
	if c - 2 < a:
		a = c - 2
	else:
		c = a + 2
	if c - 1 < b:
		b = c - 1
	else:
		c = b + 1
print(a + b + c)


arr = list(map(int, input().split()))
y = arr[0]
b = arr[1]
r = arr[2]
x = 1
a = 2
z = 3
while x < y and z < r and (a < b):
	x = x + 1
	a = a + 1
	z = z + 1
s = x + a + z
print(s)


(y, b, r) = map(int, input().split())
m = min(y, b, r)
if m == r:
	ans = r + (r - 1) + (r - 2)
elif m == b and m + 1 > r:
	ans = r + (r - 1) + (r - 1)
elif m == b and m + 1 <= r:
	ans = b + (b - 1) + (b + 1)
elif m == y and m + 2 > r:
	ans = r + (r - 1) + (r - 2)
elif m == y and m + 2 <= r:
	ans = y + (y + 1) + (y + 2)
print(ans)


(a, b, c) = map(int, input().split())
x = min(a, b - 1, c - 2)
print(3 * x + 3)


(y, b, r) = [int(x) for x in input().split()]
if 1 <= y <= 100 and 2 <= b <= 100 and (3 <= r <= 100):
	if y < b < r:
		print(3 * y + 3)
	elif b <= y < r or b < r <= y:
		print(3 * b)
	elif r <= b <= y or r < y <= b:
		print(3 * r - 3)
	elif y < r <= b and r >= y + 2:
		print(3 * y + 3)
	else:
		print(3 * r - 3)
else:
	print('invalid inputs')


l = list(map(int, input().split()))
print(min(l[0] * 3 + 3, l[1] * 3, l[2] * 3 - 3))


def ornaments(y, b, r):
	l = min(y, b - 1, r - 2)
	print(3 * l + 3)
(y, b, r) = map(int, input().split())
ornaments(y, b, r)


(y, b, r) = [int(i) for i in input().split()]
x = [y, b, r]
if y < b < r:
	print(3 * y + 3)
elif y == r == b:
	print(3 * r - 3)
elif min(x) == r:
	print(3 * r - 3)
elif min(x) == b and b != r:
	print(3 * b)
elif min(x) == y and y != r and (y != b):
	if b > r:
		if r - y <= 2:
			print(3 * r - 3)
		else:
			print(3 * y + 3)
	elif b == r:
		if r - y == 1:
			print(3 * r - 3)
		elif r - y > 1:
			print(3 * y + 3)


(y, b, r) = list(map(int, input().split()))
(ye, bl, re) = (r - 2, r - 1, r)
while re > r or ye > y or bl > b:
	(re, ye, bl) = (re - 1, ye - 1, bl - 1)
print(re + ye + bl)


(a, b, c) = map(int, input().split())
if c - b >= 1:
	if b - a >= 1:
		print(3 * a + 3)
	else:
		print(3 * b)
elif b - a >= 1:
	if c - a >= 2:
		print(3 * a + 3)
	else:
		print(3 * c - 3)
else:
	print(3 * c - 3)


(y, b, r) = map(int, input().split(' '))
while b >= r:
	b = b - 1
while y >= b:
	y = y - 1
while b - 1 > y:
	b = b - 1
while r - 1 > b:
	r = r - 1
print(y + b + r)


n = list(map(int, input().split()))
y = n[0]
b = n[1]
r = n[2]
x = 1
Y = 2
z = 3
while z < r and Y < b and (x < y):
	x = x + 1
	Y = Y + 1
	z = z + 1
s = x + Y + z
print(s)


(a, b, c) = map(int, input().rstrip().split())
d = c - 2 if c - 2 <= a else a
e = b - 1 if b - 1 <= a else a
print(3 * min(d, e) + 3)


(y, b, r) = list(map(int, input().split()))
if y <= b - 1 and y <= r - 2:
	print(y * 3 + 3)
elif b < y + 1 and b <= r - 1:
	print((b - 1) * 3 + 3)
else:
	print((r - 2) * 3 + 3)


(y, b, r) = map(int, input().split())

def solve(y, b, r):
	y = min([y, b, r])
	while y:
		if b >= y + 1 and r >= y + 2:
			return 3 * (y + 1)
		y -= 1
print(solve(y, b, r))


(a, b, c) = map(int, input().split())
for i in range(c, 1, -1):
	if i - 1 <= b and i - 2 <= a:
		print(3 * i - 3, '\n')
		break


(y, b, r) = map(int, input().split())
miner = min(y, b, r)
if r == miner:
	print(r + r - 1 + r - 2)
elif b == miner:
	if b + 1 > r:
		b = b - 1
	print(b - 1 + b + b + 1)
else:
	if y + 1 > b or y + 1 > r or y + 2 > r:
		y -= 1
	print(y + y + 1 + y + 2)


l = input().split()
y = int(l[0])
bl = int(l[1])
r = int(l[2])
m = int(max(l))
a = 0
b = a + 1
c = b + 1
for i in range(m + 1):
	a += 1
	b += 1
	c += 1
	if a <= y and b <= bl and (c <= r):
		v = a + b + c
	else:
		break
		v = 0
print(v)


(y, b, r) = map(int, input().split())
my_y = y
my_b = b
my_r = r
if y + 1 <= b:
	my_b = y + 1
else:
	my_y = my_b - 1
if my_b + 1 <= r:
	my_r = my_b + 1
else:
	my_b = my_r - 1
	my_y = my_b - 1
print(my_y + my_b + my_r)


(y, b, r) = [int(i) for i in input().split()]
if r >= y and b > y:
	if r == y + 1 or r == y:
		y = r - 2
		b = y + 1
		print(r + b + y)
	elif r > y + 1:
		r = y + 2
		b = y + 1
		print(y + r + b)
elif y >= b and r >= b:
	if b == r:
		y = r - 2
		b = y + 1
		r = y + 2
		print(r + b + y)
	else:
		y = b - 1
		r = b + 1
		print(y + b + r)
elif y > r and b > r:
	y = r - 2
	b = r - 1
	print(r + b + y)


def main():
	(y, b, r) = map(int, input().split())
	b -= 1
	r -= 2
	print(min(y, b, r) * 3 + 3)
main()


gi = lambda : list(map(int, input().split()))
(y, b, r) = l = gi()
ans = 0
if b < 2 or r < 3:
	print(0)
	exit()
else:
	ans = 6
	y -= 1
	b -= 2
	r -= 3
while r and b and y:
	ans += 3
	y -= 1
	r -= 1
	b -= 1
print(ans)


(y, b, r) = map(int, input().split())
y1 = 1
b1 = 2
r1 = 3
while y1 < y and b1 < b and (r1 < r):
	y1 = y1 + 1
	b1 = b1 + 1
	r1 = r1 + 1
s = y1 + b1 + r1
print(s)


(y, bl, r) = [int(x) for x in input().split()]
a = y
b = bl
c = r
h = 'True'
while h:
	b = a + 1
	c = b + 1
	if b <= bl and c <= r and (a <= y):
		print(a + b + c)
		break
	else:
		a = a - 1


def go():
	(y, b, r) = [int(i) for i in input().split(' ')]
	x = min(y, b, r)
	if x == r:
		return r + r - 1 + r - 2
	elif x == b:
		return b + 1 + b + b - 1
	elif r >= y + 2:
		return y + y + 1 + y + 2
	else:
		return y - 1 + y + y + 1
print(go())


(y, b, r) = map(int, input().split())
b = min(y + 1, b, r - 1)
if b < 0:
	print(0)
else:
	print(3 * b)


from math import *
(y, b, r) = map(int, input().split())
print(min(y + 1, b, r - 1) * 3)


(y, b, r) = (0, 0, 0)
while y < 1 or b < 2 or r < 3 or (y > 100) or (b > 100) or (r > 100):
	(y, b, r) = map(int, input().split())
if r > b:
	if b > y:
		Max = y + y + 1 + y + 2
	else:
		Max = b + b - 1 + b + 1
elif b > y:
	if y + 1 < r:
		Max = y + y + 1 + y + 2
	else:
		Max = r + r - 1 + r - 2
else:
	Max = r + r - 1 + r - 2
print(Max)


m = 100
a = []
s = input()
x = s.split()
a = [eval(y) for y in x]
for i in range(3):
	l = a[i] - i
	if m > l:
		m = l
print(m * 3 + 3)


(a, b, c) = map(int, input().split())
c1 = 0
while a > 0:
	if a + 1 <= b and a + 2 <= c:
		c1 = 3 * a + 3
		print(c1)
		break
	else:
		a -= 1


(y, b, r) = [int(s) for s in input().split(' ')]
print(3 * (min(r, b + 1, y + 2) - 1))


tNum = input().split()
nums = []
for n in tNum:
	nums.append(int(n))
if nums[0] >= nums[2] - 2 and nums[1] >= nums[2] - 1:
	print(nums[2] + nums[2] - 1 + nums[2] - 2)
elif nums[0] >= nums[1] - 1 and nums[2] >= nums[1] + 1:
	print(nums[1] + nums[1] - 1 + nums[1] + 1)
else:
	print(nums[0] + nums[0] + 1 + nums[0] + 2)


x = list(map(int, input().split()))
y = x[0]
b = x[1]
r = x[2]
X = 1
Y = 2
Z = 3
while Z < r and Y < b and (X < y):
	X = X + 1
	Y = Y + 1
	Z = Z + 1
print(X + Y + Z)


from operator import itemgetter
(y, b, r) = map(int, input().split())
print(min(min(y + 2, b + 1), r) * 3 - 3)


(y, b, r) = [int(x) for x in input().split()]
while y >= 1 and b >= 2 and (r >= 3):
	for k in range(1, y + 1):
		y = bool(k + 1 <= b and k + 2 <= r)
		if y == True:
			result = k + k + 1 + k + 2
	break
print(result)


x = list(map(int, input().split()))
print(min(x[0], x[1] - 1, x[2] - 2) * 3 + 3)


(y, b, r) = map(int, input().split())
a = []
a.append(y)
a.append(y + 1)
a.append(y + 2)
while a[1] > b:
	a[0] -= 1
	a[1] -= 1
	a[2] -= 1
while a[2] > r:
	a[0] -= 1
	a[1] -= 1
	a[2] -= 1
print(sum(a))


import sys
input = sys.stdin.readline
print = sys.stdout.write
(y, b, r) = map(int, input().split())
print(str(3 * min(y + 1, b, r - 1)))


import math, sys
from fractions import *

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

def main():
	(a, b, c) = mp()
	ans = 6
	for i in range(1, a + 1):
		if i + 1 <= b and i + 2 <= c:
			ans = max(ans, 3 * i + 3)
	print(ans)
deb = 0
if deb:
	file = open('input.txt', 'w')
else:
	input = sys.stdin.readline
main()


(y, b, r) = map(int, input().split())
a = [(y + 2, 3, 'y'), (b + 1, 2, 'b'), (r, 1, 'r')]
a.sort()
if a[0][2] == 'y':
	print(sum((y, y + 1, y + 2)))
elif a[0][2] == 'b':
	print(sum((b - 1, b, b + 1)))
else:
	print(sum((r - 2, r - 1, r)))


(y, b, r) = map(int, input().split())
bb = b - 1
rr = r - 2
mn = min([y, bb, rr])
if y == mn:
	print(3 * y + 3)
elif bb == mn:
	print(3 * b)
elif rr == mn:
	print(3 * r - 3)


a = list(map(int, input().split()))
y = a[0] + 1
b = a[1]
r = a[2] - 1
c = 3 * min(y, b, r)
print(c)


(a, b, c) = [int(s) for s in input().split()]
print(min(a, b - 1, c - 2) * 3 + 3)


(y, b, r) = map(int, input().split())
if y <= b and y <= r:
	while y > 0:
		d1 = b - y
		d2 = r - y
		if d1 >= 1 and d2 >= 2:
			print(3 * y + 3)
			break
		else:
			y -= 1
elif b <= y and b < r:
	y = b - 1
	print(3 * y + 3)
elif r <= y and r <= b:
	y = r - 2
	print(3 * y + 3)


from sys import stdin
arr = [int(ch) for ch in stdin.readline().split()]
(actual_y, b, r) = arr
for y in range(actual_y, 0, -1):
	if y + 1 <= b and y + 2 <= r:
		print(3 * y + 3)
		break


(a, b, c) = [int(i) for i in input().strip().split()]
if a >= b:
	a = b - 1
else:
	b = a + 1
if c >= b + 1:
	c = b + 1
else:
	b = c - 1
	a = b - 1
print(a + b + c)


l = [int(i) for i in input().split()]
l[0] += 2
l[1] += 1
n = min(l)
print(n * 3 - 3)


(y, b, r) = tuple(map(int, input().split()))
t = min(y, b - 1, r - 2)
if t == y:
	print(y + y + 1 + y + 2)
elif t == b - 1:
	print(b - 1 + b + b + 1)
else:
	print(r + r - 1 + r - 2)


(y, b, r) = [int(i) for i in input().split()]
m = min([y, b, r])
(y1, b1, r1) = [m, m + 1, m + 2]
while y < y1 or b < b1 or r < r1:
	m = m - 1
	(y1, b1, r1) = [m, m + 1, m + 2]
print(y1 + b1 + r1)


(a, b, c) = map(int, input().split())
(a, b, c) = (c, b, a)
res = 6
if a - 1 <= b and a - 2 <= c:
	res = max(res, a + a - 1 + a - 2)
if b + 1 <= a and b - 1 <= c:
	res = max(res, b + 1 + b + b - 1)
if c + 1 <= b and c + 2 <= a:
	res = max(res, c + c + 1 + c + 2)
print(res)


from sys import stdin, stdout
import cProfile, math
from collections import Counter
from bisect import bisect_left, bisect, bisect_right
import itertools
from copy import deepcopy
from fractions import Fraction
import sys, threading
import operator as op
from functools import reduce
sys.setrecursionlimit(10 ** 6)
threading.stack_size(2 ** 27)
printHeap = str()
memory_constrained = False
P = 10 ** 9 + 7
import sys
sys.setrecursionlimit(10000000)

class Operation:

	def __init__(self, name, function, function_on_equal, neutral_value=0):
		self.name = name
		self.f = function
		self.f_on_equal = function_on_equal

def add_multiple(x, count):
	return x * count

def min_multiple(x, count):
	return x

def max_multiple(x, count):
	return x
sum_operation = Operation('sum', sum, add_multiple, 0)
min_operation = Operation('min', min, min_multiple, 1000000000.0)
max_operation = Operation('max', max, max_multiple, -1000000000.0)

class SegmentTree:

	def __init__(self, array, operations=[sum_operation, min_operation, max_operation]):
		self.array = array
		if type(operations) != list:
			raise TypeError('operations must be a list')
		self.operations = {}
		for op in operations:
			self.operations[op.name] = op
		self.root = SegmentTreeNode(0, len(array) - 1, self)

	def query(self, start, end, operation_name):
		if self.operations.get(operation_name) == None:
			raise Exception('This operation is not available')
		return self.root._query(start, end, self.operations[operation_name])

	def summary(self):
		return self.root.values

	def update(self, position, value):
		self.root._update(position, value)

	def update_range(self, start, end, value):
		self.root._update_range(start, end, value)

	def __repr__(self):
		return self.root.__repr__()

class SegmentTreeNode:

	def __init__(self, start, end, segment_tree):
		self.range = (start, end)
		self.parent_tree = segment_tree
		self.range_value = None
		self.values = {}
		self.left = None
		self.right = None
		if start == end:
			self._sync()
			return
		self.left = SegmentTreeNode(start, start + (end - start) // 2, segment_tree)
		self.right = SegmentTreeNode(start + (end - start) // 2 + 1, end, segment_tree)
		self._sync()

	def _query(self, start, end, operation):
		if end < self.range[0] or start > self.range[1]:
			return None
		if start <= self.range[0] and self.range[1] <= end:
			return self.values[operation.name]
		self._push()
		left_res = self.left._query(start, end, operation) if self.left else None
		right_res = self.right._query(start, end, operation) if self.right else None
		if left_res is None:
			return right_res
		if right_res is None:
			return left_res
		return operation.f([left_res, right_res])

	def _update(self, position, value):
		if position < self.range[0] or position > self.range[1]:
			return
		if position == self.range[0] and self.range[1] == position:
			self.parent_tree.array[position] = value
			self._sync()
			return
		self._push()
		self.left._update(position, value)
		self.right._update(position, value)
		self._sync()

	def _update_range(self, start, end, value):
		if end < self.range[0] or start > self.range[1]:
			return
		if start <= self.range[0] and self.range[1] <= end:
			self.range_value = value
			self._sync()
			return
		self._push()
		self.left._update_range(start, end, value)
		self.right._update_range(start, end, value)
		self._sync()

	def _sync(self):
		if self.range[0] == self.range[1]:
			for op in self.parent_tree.operations.values():
				current_value = self.parent_tree.array[self.range[0]]
				if self.range_value is not None:
					current_value = self.range_value
				self.values[op.name] = op.f([current_value])
		else:
			for op in self.parent_tree.operations.values():
				result = op.f([self.left.values[op.name], self.right.values[op.name]])
				if self.range_value is not None:
					bound_length = self.range[1] - self.range[0] + 1
					result = op.f_on_equal(self.range_value, bound_length)
				self.values[op.name] = result

	def _push(self):
		if self.range_value is None:
			return
		if self.left:
			self.left.range_value = self.range_value
			self.right.range_value = self.range_value
			self.left._sync()
			self.right._sync()
			self.range_value = None

	def __repr__(self):
		ans = '({}, {}): {}\n'.format(self.range[0], self.range[1], self.values)
		if self.left:
			ans += self.left.__repr__()
		if self.right:
			ans += self.right.__repr__()
		return ans

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

def ncr(n, r):
	r = min(r, n - r)
	numer = reduce(op.mul, range(n, n - r, -1), 1)
	denom = reduce(op.mul, range(1, r + 1), 1)
	return numer / denom

def primeFactors(n):
	factors = dict()
	for i in range(2, math.ceil(math.sqrt(n)) + 1):
		while n % i == 0:
			if i in factors:
				factors[i] += 1
			else:
				factors[i] = 1
			n = n // i
	if n > 2:
		factors[n] = 1
	return factors

def isprime(n):
	if n < 4:
		return True
	if n % 2 == 0:
		return False
	if n % 3 == 0:
		return False
	i = 5
	w = 2
	while i * i <= n:
		if n % i == 0:
			return False
		i += w
		w = 6 - w
	return True

def test_print(*args):
	if testingMode:
		print(args)

def display_list(list1, sep=' '):
	stdout.write(sep.join(map(str, list1)) + '\n')

def get_int():
	return int(stdin.readline().strip())

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

def get_list():
	return list(map(int, stdin.readline().split()))
memory = dict()

def clear_cache():
	global memory
	memory = dict()

def cached_fn(fn, *args):
	global memory
	if args in memory:
		return memory[args]
	else:
		result = fn(*args)
		memory[args] = result
		return result
TestCases = False
testingMode = False
optimiseForReccursion = False

def main():
	(y, b, r) = get_tuple()
	b -= 1
	r -= 2
	print(min(y, b, r) * 3 + 3)
if TestCases:
	for _ in range(get_int()):
		cProfile.run('main()') if testingMode else main()
else:
	(cProfile.run('main()') if testingMode else main()) if not optimiseForReccursion else threading.Thread(target=main).start()


(y, b, r) = map(int, input().split())
a = 0
c = 1
d = 2
while a + c + d < y + b + r and a < y and (c < b) and (d < r):
	a = a + 1
	c = c + 1
	d = d + 1
print(a + c + d)


arr = [int(x) for x in input().split()]
min_num = min(arr[0], arr[1])
min_num = min(min_num, arr[2])
min_index = arr.index(min_num)
if min_index > 0:
	min_num -= min_index
	arr[0] = min_num
i = 0
while i < 2:
	if arr[i] + 1 == arr[i + 1]:
		i += 1
	elif arr[i] + 1 < arr[i + 1]:
		arr[i + 1] -= 1
	elif arr[i] + 1 > arr[i + 1]:
		for x in range(0, i + 1):
			arr[x] -= 1
print(sum(arr))


def my_fun(x, y, z):
	if z - 1 <= y and y - 1 <= x:
		print(3 * (z - 1))
	elif not z - 1 <= y and y - 1 <= x:
		z = z - 1
		my_fun(x, y, z)
	elif z - 1 <= y and (not y - 1 <= x):
		y = y - 1
		my_fun(x, y, z)
	else:
		z = z - 1
		y = y - 1
		my_fun(x, y, z)
aux = input().split(' ')
i = 0
while i < 3:
	aux[i] = int(aux[i])
	i += 1
my_fun(aux[0], aux[1], aux[2])


(y, b, r) = map(int, input().split())
a = min(y, b - 1, r - 2)
answer = 3 * a + 3
print(answer)


arry = [int(y) for y in input().split()]
mn = min(arry[0], arry[1])
mnindex = arry.index(mn)
if arry[0] == arry[1]:
	mn = arry[1]
	mnindex = 1
if mnindex == 1 and mn < arry[-1] - 1:
	print(mn + mn - 1 + mn + 1)
elif mnindex == 0 and mn < arry[-1] - 2:
	print(mn + mn + 1 + mn + 2)
else:
	print(arry[-1] + arry[-1] - 1 + arry[-1] - 2)


from bisect import bisect_left as bl
from bisect import bisect_right as br
import heapq
import math
from collections import *
from functools import reduce, cmp_to_key
import sys
input = sys.stdin.readline
M = mod = 10 ** 9 + 7

def factors(n):
	return sorted(list(set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))))

def inv_mod(n):
	return pow(n, mod - 2, mod)

def li():
	return [int(i) for i in input().rstrip('\n').split(' ')]

def st():
	return input().rstrip('\n')

def val():
	return int(input())

def li2():
	return [i for i in input().rstrip('\n').split(' ')]

def li3():
	return [int(i) for i in input().rstrip('\n')]
(y, b, r) = li()
b -= 1
r -= 2
print(3 * min(y, b, r) + 3)


toys = input().split()
y = int(toys[0])
b = int(toys[1])
r = int(toys[2])
y1 = 1
b1 = 2
r1 = 3
while True:
	if y1 == y or b1 == b or r1 == r:
		break
	else:
		y1 += 1
		b1 += 1
		r1 += 1
print(y1 + b1 + r1)


(y, b, r) = [int(x) for x in input().split()]
if y == b and b == r:
	y = r - 2
	b = r - 1
if y == b and y > r:
	y = r - 2
	b = r - 1
elif y == b and y < r and (y + 1 != r):
	y = y - 1
	r = b + 1
elif b == r and y <= b and (y + 1 != r):
	b = y + 1
	r = b + 1
elif b == r and y >= b and (y + 1 != r):
	y = r - 2
	b = r - 1
elif y > b > r:
	y = r - 2
	b = r - 1
elif y < b < r:
	b = y + 1
	r = y + 2
elif y < b > r and y < r and (y + 1 != r):
	b = y + 1
	r = y + 2
elif y < b > r and y < r and (y + 1 == r):
	y = y - 1
	b = y + 1
	r = y + 2
elif y < b > r and y > r:
	y = r - 2
	b = r - 1
elif y > b:
	if b >= r:
		y = r - 2
		b = r - 1
	else:
		r = b + 1
		y = b - 1
elif b >= r:
	y = r - 2
	b = r - 1
else:
	b = y + 1
	r = y + 2
print(y + b + r)


(y, b, r) = [int(w) for w in input().split()]
print(3 * min(y + 1, b, r - 1))


a = 0
b = 0
c = 0
(a, b, c) = map(int, input().split())
least = 99999999999
least = min(a, least)
least = min(b - 1, least)
least = min(c - 2, least)
print(least * 3 + 3)


(y, b, r) = map(int, input().split())
a = 1
m = 2
c = 3
l = True
while l:
	if a > y or m > b or c > r:
		a = a - 1
		m = m - 1
		c = c - 1
		l = False
		break
	a = a + 1
	m = m + 1
	c = c + 1
print(a + m + c)


while True:
	try:
		(y, b, r) = map(int, input().strip().split())
		ans = min(3 * y + 3, 3 * b, 3 * r - 3)
		print(ans)
	except EOFError:
		break


a = input().split(' ')
a = list(map(int, a))
y = a[0]
b = a[1]
r = a[2]
a = []
for i in range(1, y + 1):
	for j in range(1, b + 1):
		for k in range(1, r + 1):
			if i + 1 == j and j + 1 == k:
				s = i + j + k
				a.append(s)
print(max(a))


(y, b, r) = list(map(int, input().split()))
max_y = min(b - 1, r - 2, y)
print(3 * max_y + 3)


def sol(y, b, r):
	m = min(y + 2, b + 1, r)
	return m * 3 - 3
(y, b, r) = map(int, input().split())
d = sol(y, b, r)
print(d)


x = [int(x) for x in input().split()]
if min(x[0], x[1], x[2]) == x[0]:
	y = x[0]
	b = x[0] + 1
	r = x[0] + 2
	while b > x[1] or r > x[2]:
		y = y - 1
		b = b - 1
		r = r - 1
elif min(x[0], x[1], x[2]) == x[1]:
	y = x[1] - 1
	b = x[1]
	r = x[1] + 1
	while b > x[1] or r > x[2]:
		y = y - 1
		b = b - 1
		r = r - 1
else:
	y = x[2] - 2
	b = x[2] - 1
	r = x[2]
	while b > x[1] or r > x[2]:
		y = y - 1
		b = b - 1
		r = r - 1
print(y + b + r)


(y, b, r) = map(int, input().split(' '))
an = []
if y + 1 <= b and y + 2 <= r:
	an.append(y * 3 + 3)
if b - 1 <= y and b + 1 <= r:
	an.append(3 * b)
if r - 2 <= y and r - 1 <= b:
	an.append(3 * r - 3)
if an == []:
	print('-1')
else:
	print(min(an))


import math
from collections import *
import sys
from functools import reduce

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

def get_list():
	return list(get_ints())

def get_string():
	return list(input().strip().split())

def printxsp(*args):
	return print(*args, end='')

def printsp(*args):
	return print(*args, end=' ')
UGLYMOD = int(1000000000.0) + 7
SEXYMOD = 998244353
MAXN = int(100000.0)
(a, b, c) = get_ints()
mn = min(a, b - 1, c - 2)
print(3 * mn + 3)


(y, b, r) = map(int, input().split())
A = []
if y + 1 <= b and y + 2 <= r:
	A.append(3 * y + 3)
elif b - 1 <= y and b + 1 <= r:
	A.append(3 * b)
elif r - 2 <= y and r - 1 <= b:
	A.append(3 * r - 3)
print(max(A))


(y, b, r) = map(int, input().split())
result = 6
if b >= y + 1 and r >= y + 2:
	result = max(result, y * 3 + 3)
if y >= b - 1 and r >= b + 1:
	result = max(result, (b - 1) * 3 + 3)
if y >= r - 2 and b >= r - 1:
	result = max(result, (r - 2) * 3 + 3)
print(result)


(y, b, r) = [int(i) for i in input().split()]
a = y + 2
c = b + 1
d = r
if d < c and d <= a:
	print((r - 1) * 3)
elif c <= a and c <= d:
	print(b * 3)
else:
	print((y + 1) * 3)


(x, y, z) = [*map(int, input().split())]
print((min(x, y - 1, z - 2) + 1) * 3)


(y, b, r) = map(int, input().split())
if b >= r:
	b = r - 1
if y >= b:
	y = b - 1
mn = min(y, b, r)
print(mn + (mn + 1) + (mn + 2))


(y, b, r) = map(int, input().split())
b1 = b - 1
r1 = r - 2
if y <= b1 and y <= r1:
	max = 3 * y + 3
elif b1 <= y and b1 <= r1:
	max = 3 * b
elif r1 <= b1 and r1 <= y:
	max = 3 * r - 3
print(max)


def function(l):
	(y, b, r) = l
	x = min(l)
	if y == b and x != r:
		print(3 * (y - 1) + 3)
	elif b == r and x != y:
		print(3 * (b - 1))
	elif x == y:
		if y + 2 > r:
			print(3 * r - 3)
		else:
			print(3 * y + 3)
	elif x == b:
		print(3 * b)
	else:
		print(3 * r - 3)
l = []
l = list(map(int, input().split()))
function(l)


def main():
	(x, y, z) = list(map(int, input().split()))
	print(min(3 * (x + 1), min(3 * y, 3 * (z - 1))))
main()


import collections
import math
import itertools
try:
	(x, y, z) = map(int, input().split())
	t = max(x, y, z)
	for i in range(1, t):
		if x / i == 1.0 or y / (i + 1) == 1.0 or z / (i + 2) == 1.0:
			print(i + i + 1 + i + 2)
			break
		else:
			pass
except:
	pass


import sys
input = sys.stdin.readline

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

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

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())
(y, b, r) = invr()
mi = min(y, b, r)
ma = max(y, b, r)
if mi == y and mi != r and (mi != b):
	b = y + 1
	if b + 1 > r:
		b = r - 1
		y = b - 1
	else:
		r = b + 1
elif mi == b and mi != r:
	y = b - 1
	r = b + 1
elif mi == r:
	b = r - 1
	y = b - 1
print(y + r + b)


(a, b, c) = [int(x) for x in input().split()]
for i in range(a, 0, -1):
	if i + 1 <= b:
		temp = i + 1
		if i + 2 <= c:
			temp2 = i + 2
			print(i + temp + temp2)
			break


ligne = input().split(' ')
a = int(ligne[0])
b = int(ligne[1])
c = int(ligne[2])
if c == min(a, b, c):
	print(c + c - 1 + c - 2)
elif b == min(a, b, c):
	print(b + 1 + b + b - 1)
elif c - a < 2:
	print(a - 1 + a + a + 1)
else:
	print(a + a + 1 + a + 2)


(y, b, r) = [int(i) for i in input().split()]
res = 0
ct = 0
while ct < 1:
	if y + 1 <= b and y + 2 <= r:
		ct = 1
		res = y + y + 1 + y + 2
	else:
		y -= 1
print(res)


(y, b, r) = map(int, input().split())
a = min(y, b, r)
if a == y:
	if b > a and r > a + 1:
		print(3 * a + 3)
	elif b == a and r > y:
		print(3 * y)
	elif r == a:
		print(3 * y - 3)
	elif r == y + 1:
		print(3 * r - 3)
elif a == b:
	if r > b:
		print(3 * a)
	else:
		print(3 * a - 3)
else:
	print(3 * a - 3)


(y, b, r) = map(int, input().split())
b -= 1
r -= 2
m = min(y, b, r)
if m == y:
	print(y * 3 + 3)
elif m == b:
	print(b * 3 + 3)
else:
	print(r * 3 + 3)


def maxOrnaments(y, b, r):
	return min(y, b - 1, r - 2) * 3 + 3
(y, b, r) = map(int, input().split())
print(maxOrnaments(y, b, r))


def main():
	a = list(map(int, input().split()))
	ans = 0
	for i in range(1, a[0] + 1):
		if i + 1 <= a[1] and i + 2 <= a[2]:
			ans = max(ans, i * 3 + 3)
	print(ans)
main()


a = list(map(int, input().split()))
x = 0
for i in range(a[0] + 1):
	if a[1] >= i + 1 and a[2] >= i + 2:
		x = i * 3 + 3
print(x)


def main():
	(y, b, r) = map(int, input().split())
	(y, cur_b, cur_r) = (y, y + 1, y + 2)
	if b - cur_b < 0:
		y -= cur_b - b
		cur_b = b
		cur_r = y + 2
	if r - cur_r < 0:
		y -= cur_r - r
		cur_r = r
		cur_b = y + 1
	print(y + cur_b + cur_r)
main()


(y, b, r) = list(map(int, input().split()))
if b > y + 1:
	b = y + 1
else:
	y = b - 1
if r > b + 1:
	r = b + 1
else:
	b = r - 1
	y = b - 1
print(y + b + r)


def ans(arr):
	(y, b, r) = (arr[0], arr[1], arr[2])
	return min(y + 2, min(b + 1, r)) * 3 - 3
ybr = list(map(int, input().strip().split()))
print(ans(ybr))


l = list(map(int, input().split()))
if l[0] == l[1] and l[1] == l[2]:
	s = 3 * (l[0] - 2) + 3
else:
	m = l.index(min(l))
	if m == 2:
		s = 3 * l[2] - 3
	elif m == 1:
		if l[2] >= l[1] + 1:
			s = 3 * l[1]
		else:
			s = 3 * (l[1] - 1)
	elif l[1] >= l[0] + 1 and l[2] >= l[0] + 2:
		s = 3 * l[0] + 3
	elif l[1] >= l[0] + 1 and (l[2] == l[0] + 1 or l[2] == l[0]):
		if l[2] == l[0] + 1:
			s = 3 * (l[0] - 1) + 3
		elif l[2] == l[0]:
			s = 3 * (l[0] - 2) + 3
	elif l[2] >= l[0] + 2 and l[1] == l[0]:
		s = 3 * (l[0] - 1) + 3
	else:
		s = 3 * (l[0] - 2) + 3
print(s)


MOD = 10 ** 9 + 7
I = lambda : list(map(int, input().split()))
(y, b, r) = I()
for i in range(100, 1, -1):
	if r >= i and b >= i - 1 and (y >= i - 2):
		print(3 * i - 3)
		break


import sys
input = sys.stdin.readline
mii = lambda : map(int, input().split())
(a, b, c) = mii()
b -= 1
c -= 2
print(min(a, b, c) * 3 + 3)


(y, b, r) = map(int, input().split())
for i in range(y, 1, -1):
	if b - i > 0 and r - (i + 1) > 0:
		print(sum([i, i + 1, i + 2]))
		exit(0)
print(6)


(a, b, c) = map(int, input().split())
print(3 * min(a + 1, min(b, c - 1)))


import sys
(y, b, r) = list(map(int, sys.stdin.readline().split()))
ba = b - 1
ra = r - 2
m = min(y, ba, ra)
print(3 * m + 3)


(y, b, r) = list(map(int, input().strip().split()))
a = 0
if b >= y + 1 and r >= y + 2:
	a = max(a, sum([y, y + 1, y + 2]))
if b - 1 <= y and b + 1 <= r:
	a = max(a, sum([b - 1, b, b + 1]))
if r - 1 <= b and r - 2 <= y:
	a = max(a, sum([r - 2, r - 1, r]))
print(a)


def A():
	ybr = input().split()
	(y, b, r) = (int(ybr[0]), int(ybr[1]), int(ybr[2]))
	a = min(y, b - 1, r - 2)
	print(3 * a + 3)
A()


a = list(map(int, input().split()))
ans = 0
for i in range(1, a[0] + 1):
	for j in range(2, a[1] + 1):
		for k in range(3, a[2] + 1):
			if i + 1 == j and j + 1 == k:
				ans = max(ans, i + j + k)
print(ans)


(x, y, z) = input().split()
print(3 * min(int(x) + 1, min(int(y), int(z) - 1)))


(y, b, r) = list(map(int, input().split()))
ans = [0]
for i in range(1, y + 1):
	if r >= i + 2 and b >= i + 1:
		ans.append(3 * i + 3)
print(max(ans))


(y, b, r) = [int(x) for x in input().split(' ')]
n = min(y, b - 1, r - 2)
print(3 * n + 3)


(y, b, r) = map(int, input().split())
l = 1
m = 2
n = 3
while l != y and m != b and (n != r):
	l = l + 1
	m = m + 1
	n = n + 1
s = l + m + n
print(s)


(y, b, r) = map(int, input().split())
mn = min([y, b, r])
if r == min([y, b, r]):
	while not b + 1 >= r <= y + 2:
		r -= 1
	print(r + r - 1 + r - 2)
elif b == min([y, b, r]):
	while not r >= b + 1 <= y + 2:
		b -= 1
	print(3 * b)
elif y == min([y, b, r]):
	while not r >= y + 2 <= b + 1:
		y -= 1
	print(3 * y + 3)


(y, b, r) = map(int, input().split())
(x, a, z) = (1, 2, 3)
ans = x + a + z
while x < y and a < b and (z < r):
	x += 1
	a += 1
	z += 1
	ans += 3
print(ans)


import sys
(y, b, r) = map(int, sys.stdin.readline().split(' '))
z = min(y, b - 1, r - 2)
print(3 * z + 3)


(y, b, r) = [int(i) for i in input().split()]
n = min(y, b, r)
if r == n:
	print(3 * r - 3)
elif b == n:
	print(3 * b)
elif y == n:
	if r > b:
		print(3 * y + 3)
	elif r >= y + 2:
		print(3 * y + 3)
	else:
		print(3 * y)


(y, b, r) = map(int, input().split())
y1 = b1 = r1 = 0
if y >= b:
	y = b - 1
else:
	b = y + 1
if b >= r:
	b = r - 1
else:
	r = b + 1
if y >= b:
	y = b - 1
else:
	b = y + 1
print(y + b + r)


(y, b, r) = map(int, input().split())
o = 0
for i in range(1, y + 1):
	if i + 1 <= b and i + 2 <= r:
		o = max(o, i + i + i + 3)
print(o)


z = list(map(int, input().split()))
minimal = min(z)
x = z.index(minimal)
if z[0] == z[1] and z[1] == z[2]:
	print(z[0] + z[1] - 1 + z[2] - 2)
elif x == 2:
	print(z[2] * 3 - 3)
elif x == 1:
	if z[0] >= minimal and z[2] > minimal:
		print(z[1] * 3)
	else:
		print(z[2] + z[2] - 1 + z[2] - 2)
elif x == 0:
	if z[0] < z[1] and z[1] < z[2]:
		print(z[0] * 3 + 3)
	elif z[0] < z[1] and z[0] + 1 == z[2]:
		print(z[2] + z[2] - 1 + z[2] - 2)
	elif z[0] < z[1] and z[0] + 1 < z[2]:
		print(z[0] * 3 + 1 + 2)
	elif z[0] == z[2]:
		print(z[2] * 3 - 3)
	elif z[1] == z[0]:
		print(z[0] * 3)


s = input().split(' ')
y = int(s[0])
b = int(s[1])
r = int(s[2])
if r <= b:
	if b <= y:
		print(r + r + r - 3)
	if b > y:
		if r <= y:
			print(r + r + r - 3)
		elif r > y + 1:
			print(y + y + y + 3)
		else:
			print(r + r + r - 3)
elif r > b:
	if b > y:
		print(y + y + y + 3)
	if b <= y:
		print(b + b + b)


def pickOrnaments(y, b, r):
	while y > 0:
		if y + 1 > b or y + 2 > r:
			y -= 1
		else:
			return 3 * (y + 1)
inp = list(map(int, input().split(' ')))
y = inp[0]
b = inp[1]
r = inp[2]
print(pickOrnaments(y, b, r))


(y, b, r) = list(map(int, input().split()))
for i in range(y, -1, -1):
	if i + 1 in range(1, b + 1) and i + 2 in range(1, r + 1):
		print(3 * (i + 1))
		break


n = input().split(' ')
y = int(n[0])
b = int(n[1])
r = int(n[2])
while r >= 3 and b >= 2 and (y >= 1):
	if r == b + 1 and b == y + 1:
		break
	else:
		if r != b + 1:
			while r > b + 1:
				r = r - 1
			while b >= r:
				b = b - 1
		if b != y + 1:
			while b > y + 1:
				b = b - 1
			while y >= b:
				y = y - 1
print(y + b + r)


aa = input().split()
a = int(aa[0])
b = int(aa[1])
c = int(aa[2])
for i in range(1, a + 1):
	if i + 1 <= b and i + 2 <= c:
		ans = i + 1
print(ans * 3)


line = input().split(' ')
y = int(line[0])
b = int(line[1])
r = int(line[2])
for i in range(r, 0, -1):
	if i - 2 <= y and i - 1 <= b:
		print(i * 3 - 3)
		break


(a, b, c) = input().split()
a = int(a)
b = int(b)
c = int(c)
d = []
if a + 1 <= b and a + 2 <= c:
	d.append(3 * a + 3)
if b - 1 <= a and b + 1 <= c:
	d.append(3 * b)
if c - 1 <= b and c - 2 <= a:
	d.append(3 * c - 3)
print(max(d))


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))
(a, b, c) = get_int_list()
a = a + 2
b = b + 1
m = min(a, b, c)
print(m * 3 - 3)


(a, b, c) = (int(x) for x in input().split())
ans = -1
for i in range(1, a + 1):
	if i + 1 <= b and i + 2 <= c:
		ans = i * 3 + 3
for i in range(1, b + 1):
	if i - 1 <= a and i + 1 <= c:
		ans = max(ans, i + i - 1 + i + 1)
for i in range(1, c + 1):
	if i - 1 <= b and i - 2 <= a:
		ans = max(ans, i + i - 1 + i - 2)
print(ans)


def line(y, b, r):
	while r >= 3 and b >= 2 and (y >= 1):
		if r == b + 1 and b == y + 1:
			break
		else:
			if r != b + 1:
				while r > b + 1:
					r = r - 1
				while b >= r:
					b = b - 1
			if b != y + 1:
				while b > y + 1:
					b = b - 1
				while y >= b:
					y = y - 1
	print(r + y + b)
t = input()
t = t.split(' ')
y = int(t[0])
b = int(t[1])
r = int(t[2])
line(y, b, r)


(a, b, c) = map(int, input().split())
array = []
for i in range(1, a + 1):
	for j in range(1, b + 1):
		for k in range(1, c + 1):
			if j == i + 1 and k == j + 1:
				res = i + j + k
				array.append(res)
			else:
				count = 0
print(max(array))


(y, b, r) = map(int, input().split())
rr = r
bb = b
yy = y
if b >= rr:
	bb = rr - 1
else:
	rr = bb + 1
if yy >= bb:
	yy = bb - 1
else:
	bb = yy + 1
	rr = bb + 1
ans = bb + rr + yy
print(ans)


from sys import stdin, stdout
from math import *
from heapq import *
from collections import *

def main():
	(y, b, r) = [int(x) for x in stdin.readline().split()]
	res = min([y * 3 + 3, b * 3, r * 3 - 3])
	stdout.write(str(res))
	return 0
main()


(y, b, r) = [int(x) for x in input().split()]
a = [y, b, r]
if min(a) == a[0] and r - y >= 2 and (b - y >= 1):
	print(y + y + 1 + y + 2)
elif min(a) == a[0] and r - y < 2 and (b - y >= 1) and (r == y):
	print(y - 2 + y - 1 + y)
elif min(a) == a[0] and r - y < 2 and (b - y >= 1) and (r > y):
	print(y - 1 + y + y + 1)
elif min(a) == a[0] and r - y < 2 and (b - y < 1) and (r - b >= 2):
	print(y - 1 + y + y + 1)
elif min(a) == a[0] and r - y < 2 and (b - y < 1) and (r - b < 2):
	print(y - 2 + y - 1 + y)
elif min(a) == a[1] and r - b >= 1:
	print(b - 1 + b + b + 1)
elif min(a) == a[1] and r - b < 1:
	print(b - 2 + b - 1 + b)
elif min(a) == a[2]:
	print(r - 2 + r - 1 + r)


(a, b, c) = map(int, input().split())
(x, y, z) = (c, c - 1, c - 2)
while y > b or z > a:
	x -= 1
	y -= 1
	z -= 1
print(x + y + z)


(y, b, r) = map(int, input().split())
lst = []
lst = [y, b, r]
lst.sort()
if lst[0] == r:
	print(r - 2 + r - 1 + r)
elif lst[0] == b:
	print(b - 1 + b + b + 1)
elif lst[0] == y:
	if r - y == 1:
		print(r - 2 + r - 1 + r)
	elif r - y >= 2:
		print(y + y + 1 + y + 2)


elk = list(map(int, input().split()))
rez = 0
y = elk[0]
b = elk[1]
r = elk[2]
if b >= r:
	while r - b != 1:
		b -= 1
else:
	while r - b != 1:
		r -= 1
if y >= b:
	while b - y != 1:
		y -= 1
else:
	while b - y != 1:
		b -= 1
	while r - b != 1:
		r -= 1
rez += y + b + r
print(rez)


(a, b, c) = [int(i) for i in input().split()]
v = [c - 2, c - 1, c]
if max(c - 2 - a, c - 1 - b) > 0:
	print(3 * c - 3 - max(c - 2 - a, c - 1 - b) * 3)
else:
	print(3 * c - 3)


(a, b, c) = [int(x) for x in input().split()]
rr = min(c, b + 1)
bb = min(rr - 1, a + 1)
yy = min(bb - 1, a)
print(yy * 3 + 3)


(y, b, r) = map(int, input().split())
m = min(y, b, r)
ans = 6
for i in range(m - 2, m + 3):
	if y >= i and b >= i + 1 and (r >= i + 2):
		ans = max(ans, 3 * i + 3)
print(ans)


(a, b, c) = map(int, input().split())
for i in range(a, -1, -1):
	if i + 1 <= b and i + 2 <= c:
		print(i + i + 1 + i + 2)
		exit()


(y, b, r) = map(int, input().split())
mi = min(y, b, r)
if r == mi:
	print(mi * 3 - 3)
elif b == mi:
	print(mi * 3)
elif r >= y + 2:
	print(mi * 3 + 3)
else:
	print(mi * 3)


(y, b, r) = map(int, input().split())
while y > 0:
	if y + 1 <= b:
		if y + 2 <= r:
			print(3 * (y + 1))
			break
	y -= 1


a = input()
a = a.split()
x = int(a[0])
y = int(a[1])
z = int(a[2])
m = x
n = y - 1
o = z - 2
print(min(m, n, o) * 3 + 3)


(y, b, r) = map(int, input().split())
x = 1
while x < y and x + 1 < b and (x + 2 < r):
	x += 1
print(3 * x + 3)


temp = [int(x) for x in input().split()]
y = temp[0]
b = temp[1]
r = temp[2]
if y >= b:
	y = b - 1
else:
	b = y + 1
if b >= r:
	b = r - 1
	y = r - 2
else:
	r = b + 1
print(y + b + r)


import math
(y, b, r) = [int(s) for s in input().split(' ')]
ans = 0
for i in range(1, y + 1):
	if i + 1 > b:
		break
	if i + 2 > r:
		break
	ans = 3 * i + 3
print(ans)


import sys
import math

def main():
	(y, b, r) = map(int, input().split())
	res = 0
	for a in range(0, y + 1):
		if b >= a + 1 and r >= a + 2:
			res = max(res, a + a + 1 + a + 2)
	print(res)
main()


(a, b, c) = map(int, input().split())
ans = c
if b < ans - 1:
	ans = b + 1
if a < ans - 2:
	ans = a + 2
print(3 * ans - 3)


t = 1
for test in range(t):
	(y, b, r) = map(int, input().split())
	y = min(y, r - 2, b - 1)
	print(y + 2 + y + 1 + y)


(y, b, r) = map(int, input().strip().split())
b -= 1
r -= 2
if y <= b and y <= r:
	print(y * 3 + 3)
elif b <= y and b <= r:
	print((b + 1) * 3)
elif r <= y and r <= b:
	print((r + 2) * 3 - 3)


l = list(map(int, input().split()))
mini = min(l)
y = 0
if l[0] == mini:
	y = mini
elif l[1] == mini:
	y = mini - 1
elif l[2] == mini:
	y = mini - 2
for i in range(mini, -1, -1):
	if i + 1 <= l[1] and i + 2 <= l[2]:
		print(3 * i + 3)
		break


(y, b, r) = map(int, input().split())
for c in range(y, -1, -1):
	if c + 1 <= b and c + 2 <= r:
		print(3 * (c + 1))
		exit(0)


x = list(map(int, input().split()))
y = min(x)
s = 0
if x[0] == y:
	if y == x[1] and y == x[2]:
		s += y * 3 - 3
	elif y == x[1]:
		s += y * 3
	elif y == x[2]:
		s += y * 3 - 3
	elif y + 1 == x[2]:
		s += y * 3
	else:
		s += y * 3 + 3
elif x[1] == y:
	if y == x[2]:
		s += y * 3 - 3
	else:
		s += y * 3
else:
	s += y * 3 - 3
print(s)


(y, b, r) = [int(i) for i in input().strip().split(' ')]
yy = min(y, b - 1, r - 2)
bb = yy + 1
rr = bb + 1
print(rr + bb + yy)


L = list(map(int, input().split()))
(Y, B, R) = (L[0], L[1], L[2])
ans = 1
while 1:
	if ans <= Y and ans + 1 <= B and (ans + 2 <= R):
		ans += 1
	else:
		ans -= 1
		break
print(3 * ans + 3)


(a, b, c) = tuple(map(int, input().split(' ')))
if a > b - 1:
	a = b - 1
if b > c - 1:
	b = c - 1
	a = min(a, b - 1)
print(3 * a + 3)


(a, b, c) = list(map(int, input().split()))
use = min(a, b - 1, c - 2)
print(3 * use + 3)


nums = list(map(int, input().split()))
for i in range(3):
	nums[i] -= i
print((min(nums) + 1) * 3)


(y, b, r) = map(int, input().split())
res = r
if b < res - 1:
	res = b + 1
if y < res - 2:
	res = y + 2
print(res + res - 1 + res - 2)


(y, b, r) = map(int, input().split())
d = y
e = b - 1
f = r - 2
t = [d, e, f]
print(3 * min(t) + 3)


aa = [int(x) for x in input().split()]
y = aa[0]
b = aa[1]
r = aa[2]
max = 0
if y + 1 <= b and y + 2 <= r:
	max = y + y + 1 + y + 2
elif b - 1 <= y and b + 1 <= r:
	max = b - 1 + b + b + 1
else:
	max = r + r - 1 + r - 2
print(max)


l = list(map(int, input().split()))
l[1] = l[1] - 1
l[2] = l[2] - 2
if l[0] <= l[1] and l[0] <= l[2]:
	k = 3 * l[0] + 3
elif l[1] <= l[0] and l[1] <= l[2]:
	k = 3 * l[1] + 3
elif l[2] <= l[0] and l[2] <= l[1]:
	k = 3 * l[2] + 3
print(k)


(j, c, k) = map(int, input().split())
i = 0
while i <= j and i + 1 <= c and (i + 2 <= k):
	i += 1
print(3 * i)


a = list(map(int, input().split()))
a[1] -= 1
a[2] -= 2
k = min(a)
print(3 * k + 3)


(y, b, r) = list(map(int, input().split()))
b_y = b - 1
r_y = r - 2
print((min(y, b_y, r_y) + 1) * 3)


x = list(map(int, input().split()))
y = x[0]
b = x[1]
r = x[2]
m = 1
n = 2
o = 3
while m < y and n < b and (o < r):
	m = m + 1
	n = n + 1
	o = o + 1
print(m + n + o)


(y, b, r) = map(int, input().split(' '))
a = min(y, b, r)
i = 0
if a == y and y != b:
	if a + 1 <= b and a + 2 <= r:
		print(3 * a + 3)
	else:
		while a >= 0:
			a = a - 1
			if a + 1 and a + 2 <= r:
				print(3 * a + 3)
				break
elif a == b and b != r:
	if a + 1 <= r and a - 1 <= y:
		print(3 * b)
	else:
		while a >= 0:
			a = a - 1
			if a + 1 <= r and a - 1 <= y:
				print(3 * b)
				break
elif a == r:
	if a - 1 <= b and a - 2 <= y:
		print(3 * a - 3)
	else:
		while a >= a:
			a = a - 1
			if a - 1 <= b and a - 2 <= y:
				print(3 * a - 3)
				break


l = [int(x) for x in input().split()]
m = min(l)
result = [m, m + 1, m + 2]
while result[0] > l[0] or result[1] > l[1] or result[2] > l[2]:
	result = [result[i] - 1 for i in range(3)]
print(sum(result))


def solve():
	(a, b, c) = list(map(int, input().split()))
	print(min(a, b - 1, c - 2) * 3 + 3)
solve()


(a, b, c) = map(int, input().split(' '))
(a1, b1, c1) = (1, 2, 3)
sum1 = 0
k = True
while k:
	if a1 <= a and b1 <= b and (c1 <= c):
		sum1 = a1 + b1 + c1
		a1 += 1
		b1 += 1
		c1 += 1
	else:
		k = False
print(sum1)


(n, m, k) = map(int, input().split())
for i in range(1, n + 1):
	for j in range(1, m + 1):
		for p in range(1, k + 1):
			if j == i + 1 and p == j + 1:
				x = j + i + p
print(x)


(y, b, r) = [int(a) for a in input().split()]
if y > b:
	if y > r:
		if b >= r:
			print(3 * r - 3)
		else:
			print(3 * b)
	else:
		print(3 * b)
elif b > y:
	if b > r:
		if y > r:
			print(3 * r - 3)
		elif r - y > 1:
			print(3 * y + 3)
		else:
			print(3 * r - 3)
	elif r - y > 1:
		print(3 * y + 3)
	else:
		print(3 * r - 3)
elif b > r:
	print(3 * r - 3)
elif r - y > 1:
	print(3 * b)
else:
	print(3 * r - 3)


l = list(map(int, input().split()))
y = l[0]
b = l[1]
r = l[2]
while True:
	if r - 1 > b:
		r -= 1
	else:
		b = r - 1
		if b - 1 > y:
			b -= 1
			r -= 1
		else:
			y = b - 1
			break
print(r + y + b)


(y, b, r) = map(int, input().split())
arr = [p + q + s for p in range(y + 1) for q in range(b + 1) for s in range(r + 1) if q == p + 1 and s == q + 1]
print(max(arr))


s = list(map(int, input().split()))
z = [s[2] - 2, s[2] - 1, s[2]]
while s[1] < z[1] or s[0] < z[0]:
	z[0] = z[0] - 1
	z[1] = z[1] - 1
	z[2] = z[2] - 1
print(sum(z))


(a, b, c) = map(int, input().split())
k = True
i = 1
while k == True:
	if i <= a and i + 1 <= b and (i + 2 <= c):
		i += 1
	else:
		k = False
print((i - 1) * 3 + 3)


from sys import stdin, stdout
(y, b, r) = tuple(stdin.readline().split())
(y, b, r) = (int(y) + 2, int(b) + 1, int(r))
stdout.write(str(3 * (min(y, b, r) - 1)))


(y, b, r) = map(int, input().split())
y1 = r - 2
y2 = b - 1
b1 = y + 1
b2 = r - 1
r1 = b + 1
r2 = y + 2
Y = [y, y1, y2]
B = [b, b1, b2]
R = [r, r1, r2]
Y.sort()
B.sort()
R.sort()
print(Y[0] + B[0] + R[0])


(y, b, r) = input().split()
y = int(y)
b = int(b)
r = int(r)
c = 0
if y == 1:
	c = 6
elif b == 2:
	c = 6
elif r == 3:
	c = 6
if c == 0:
	if y < r - 2:
		r = y + 2
	if b < r - 1:
		r = b + 1
	c = r + (r - 1) + (r - 2)
print(c)


ls = list(map(int, input().split()))
for i in range(len(ls)):
	ls[i] -= i
m = min(ls)
Sum = 0
for i in range(len(ls)):
	Sum += m + i
print(Sum)


a = input()
(y, b, r) = a.split(' ')
y = int(y)
b = int(b)
r = int(r)
limit = r
sign = 'r'
if limit > b + 1:
	limit = b
	sign = 'b'
if limit > y + 2:
	limit = y
	sign = 'y'
z = limit * 3
if sign == 'r':
	print(z - 3)
elif sign == 'b':
	print(z)
else:
	print(z + 3)


(y, b, r) = input().split()
y = int(y)
b = int(b)
r = int(r)
cnt = min(y, b - 1, r - 2)
tot = 3 * cnt + 3
print(tot)


(y, b, r) = [int(i) for i in input().split()]
base = min(y, b - 1, r - 2)
print(3 * base + 3)


(y, b, r) = (int(x) for x in input().split())
while r >= 0:
	if r - 1 <= b and r - 2 <= y:
		print(3 * r - 3)
		break
	r -= 1


import sys

def main():
	(y, b, r) = map(int, sys.stdin.read().strip().split())
	if b >= r:
		b = r - 1
	if y >= b:
		y = b - 1
	return y * 3 + 3
print(main())


string = input()
stringList = string.split(' ')
list = list(map(int, stringList))
a = list[0]
b = list[1]
c = list[2]
for i in range(a, -1, -1):
	if i + 1 <= b and i + 2 <= c:
		print(i + i + 1 + i + 2)
		break


(y, b, r) = list(map(int, input().split()))
if r == min(y, r, b):
	print(3 * r - 3)
elif b == min(y, r, b):
	while b + 1 > r:
		b = b - 1
	print(3 * b)
else:
	while y + 2 > r or y + 1 > b:
		y = y - 1
	print(3 * y + 3)


(a, b, c) = (int(i) for i in input().split())
print(3 * min(a + 1, b, c - 1))


(y, b, r) = map(int, input().split())
ans = 6
y -= 1
b -= 2
r -= 3
while y > 0 and b > 0 and (r > 0):
	ans += 3
	y -= 1
	b -= 1
	r -= 1
print(ans)


(y, b, r) = map(int, input().split(' '))
c = []
for i in range(1, min(r, y, b) + 1):
	if i + 1 <= b and i + 2 <= r:
		c.append(3 * (i + 1))
print(max(c))


(y, b, r) = map(int, input().split())
mx = 6
for i in range(1, y + 1):
	if i + 1 <= b and i + 2 <= r:
		mx = 3 * i + 3
print(mx)


a = list(map(int, input().split()))
y = 0
b = 0
r = 0
if a[1] >= a[2] - 1:
	r = a[2]
	b = a[2] - 1
else:
	b = a[1]
	r = a[1] + 1
if a[0] >= b - 1:
	y = b - 1
else:
	b = a[0] + 1
	r = b + 1
	y = a[0]
print(y + b + r)


(y, b, r) = [int(v) for v in input().split()]
options = [(y, y + 1, y + 2), (b - 1, b, b + 1), (r - 2, r - 1, r)]
ans = 6
for (yy, bb, rr) in options:
	if 0 <= yy <= y and 0 <= bb <= b and (0 <= rr <= r):
		ans = max(ans, yy + bb + rr)
print(ans)


(x, y, z) = map(int, input().split())
(x1, y1, z1) = (z - 2, z - 1, z)
while True:
	if x >= x1 and y >= y1 and (z >= z1):
		print(x1 + y1 + z1)
		break
	else:
		x1 -= 1
		y1 -= 1
		z1 -= 1


(y, b, r) = list(map(int, input().split()))
if b - y > 1:
	b = y + 1
elif b - y < 1:
	y = b - 1
if r - b > 1:
	r = b + 1
elif r - b < 1:
	b = r - 1
	y = b - 1
print(y + b + r)


(y, b, r) = map(int, input().split())
ans = 6
for i in range(1, 100):
	if y > i and b > i + 1 and (r > i + 2):
		ans += 3
	else:
		break
print(ans)


(n, z, k) = map(int, input().split())
x = 0
for i in range(1, n + 1):
	for j in range(1, z + 1):
		for r in range(1, k + 1):
			if j == i + 1 and r == j + 1:
				x = j + i + r
print(x)


inp = input().split()
inp = [int(x) for x in inp]
val = 0
if min(inp) == inp[2]:
	val = 3 * inp[2] - 3
elif min(inp) == inp[1]:
	val = 3 * inp[1]
elif inp[2] >= inp[0] + 2:
	val = 3 * inp[0] + 3
else:
	val = 3 * inp[0]
print(val)


(y, b, r) = map(int, input().split())
mn = min(r, b, y)
if r == mn:
	c = r + r - 1 + r - 2
	print(c)
elif b == mn:
	c = b - 1 + b + b + 1
	print(c)
else:
	if r < y + 2:
		y -= y + 2 - r
	c = y + y + 1 + y + 2
	print(c)


import sys
(y, b, r) = map(int, sys.stdin.readline().split())
if b >= y + 1:
	b = y + 1
else:
	y = b - 1
if r >= b + 1:
	r = b + 1
else:
	b = r - 1
	y = b - 1
print(y + b + r)


(a, b, c) = map(int, input().split())
l = [a + 1, b, c - 1]
l.sort()
print(3 * l[0])


def pd(y, b, r, yy, bb, rr):
	if y >= yy and b >= bb and (r >= rr):
		return True
	return False
(y, b, r) = map(int, input().split())
ans = 0
if pd(y, b, r, y, y + 1, y + 2) == True:
	ans = max(ans, y + y + 1 + y + 2)
if pd(y, b, r, b - 1, b, b + 1) == True:
	ans = max(ans, 3 * b)
if pd(y, b, r, r - 2, r - 1, r) == True:
	ans = max(ans, 3 * r - 3)
print(ans)


(Y, B, R) = map(int, input().split())
B -= 1
R -= 2
print(3 * min(Y, B, R) + 3)


def main():
	(y, b, r) = map(int, input().split())
	while y > 0:
		if y + 1 <= b and y + 2 <= r:
			print(3 * y + 3)
			break
		y -= 1
main()


import queue

def main():
	(y, b, r) = [int(x) for x in input().split()]
	s = 0
	if min(y, b, r) == r:
		s = 3 * r - 3
	elif min(y, b, r) == b:
		s = 3 * b
	elif r > y + 1:
		s = 3 * y + 3
	else:
		s = 3 * y
	print(s)
main()


(y, b, r) = [int(x) for x in input().split()]
ans = 0
for i in range(1, y + 1):
	if b >= i + 1 and r >= i + 2:
		ans = i + i + 1 + i + 2
print(ans)


(a, b, c) = map(int, input().split())
ret = 0
s = min(a, b, c)
for i in range(1, 101):
	if i <= a and i + 1 <= b and (i + 2 <= c):
		ret = i + i + i + 3
print(ret)


(y, b, r) = map(int, input().split(' '))
while y + 2 > r or y + 1 > b:
	y -= 1
print(y + y + 1 + y + 2)


s = input()

def solution(line):
	list1 = line.split()
	n1 = int(list1[0])
	n2 = int(list1[1])
	n3 = int(list1[2])
	n4 = min(n1, n2, n3)
	if n4 == n1:
		while n2 < n1 + 1 or n3 < n1 + 2:
			n1 = n1 - 1
		return 3 * n1 + 3
	elif n4 == n2:
		while n1 < n2 - 1 or n3 < n2 + 1:
			n2 = n2 - 1
		return 3 * n2
	elif n4 == n3:
		while n1 < n3 - 2 or n2 < n3 - 1:
			n3 = n3 - 1
		return 3 * n3 - 3
print(solution(s))


vs = list(map(int, input().split()))
mv = min(vs[0], vs[1] - 1, vs[2] - 2)
print(3 * mv + 3)


(a, b, c) = [int(x) for x in input().split()]
base = min(a, b - 1, c - 2)
print(3 * base + 3)


(y, b, r) = input().split(' ')
y = int(y)
b = int(b)
r = int(r)
i = 1
j = 2
k = 3
while i <= y and j <= b and (k <= r):
	i = i + 1
	j = j + 1
	k = k + 1
sum = i + j + k - 3
print(sum)


(y, b, r) = [int(i) for i in input().split()]
p = y + 2
q = b + 1
s = r
if s <= p and s <= q:
	print(3 * (r - 1))
elif q <= s and q <= p:
	print(3 * b)
else:
	print(3 * (y + 1))


(y, b, r) = map(int, input().split())
veci = []
if y + 1 <= b and y + 2 <= r:
	veci.append(3 * y + 3)
if b - 1 <= y and b + 1 <= r:
	veci.append(3 * b)
if r - 2 <= y and r - 1 <= b:
	veci.append(3 * r - 3)
print(max(veci))


x = input().split()
y = int(x[0])
b = int(x[1])
r = int(x[2])
ans = 0
minimum = min(y, b, r)
poss = []
if minimum <= r and b >= r - 1 and (y >= r - 2):
	ans = r + r - 1 + r - 2
	poss.append(ans)
elif minimum <= b and r >= b + 1 and (y >= b - 1):
	ans = b + b - 1 + b + 1
	poss.append(ans)
elif minimum <= y and b >= y + 1 and (r >= y + 2):
	ans = y + y + 1 + y + 2
	poss.append(ans)
print(max(poss))


(a, b, c) = map(int, input().split())
m1 = 0
if a >= b - 1 and c >= b + 1:
	m1 = 3 * b
m2 = 0
if b >= a + 1 and c >= a + 2:
	m2 = 3 * a + 3
m3 = 0
if a >= c - 2 and b >= c - 1:
	m3 = 3 * c - 3
print(max(m1, m2, m3))


x = input().split(' ')
y = int(x[0])
b = int(x[1])
r = int(x[2])

def balls(y, b, r):
	if y + 1 <= b:
		if y + 2 <= r:
			r1 = y + 2
			b1 = y + 1
			y1 = y
		else:
			r1 = r
			b1 = r - 1
			y1 = r - 2
	elif b + 1 <= r:
		r1 = b + 1
		b1 = b
		y1 = b - 1
	else:
		r1 = r
		b1 = r - 1
		y1 = r - 2
	numberOfBalls = y1 + b1 + r1
	return numberOfBalls
print(balls(y, b, r))


import math
(y, b, r) = [int(x) for x in input().split()]
ans = min(y, min(b, r))
if ans == r:
	ans = 3 * (r - 1)
elif ans == b:
	ans = 3 * b
elif ans == y:
	if r == y + 1:
		ans = 3 * y
	else:
		ans = 3 * (y + 1)
print(ans)


(y, b, r) = map(int, input().split())
ya = y
ba = y + 1
ra = y + 2
m = min(y, b, r)
if m == b:
	ya = b - 1
	ba = b
	ra = b + 1
elif m == r:
	ya = r - 2
	ba = r - 1
	ra = r
if ra > r or ba > b or ya > y:
	ya -= 1
	ba -= 1
	ra -= 1
print(ya + ba + ra)


(y, b, r) = input().split(' ')
y = int(y)
b = int(b)
r = int(r)
ans = 0
if b >= r - 1 and y >= r - 2:
	ans = r + r - 1 + r - 2
elif r >= b + 1 and y >= b - 1:
	ans = b - 1 + b + b + 1
elif b >= y + 1 and r >= y + 2:
	ans = y + y + 1 + y + 2
print(ans)


(x, y, z) = map(int, input().split())
c = min(x, y - 1, z - 2)
if x == y == z:
	print(3 * x - 3)
elif c == x:
	print(3 * c + 3)
elif c == y - 1:
	print(3 * y)
elif c == z - 2:
	print(3 * z - 3)


(a, b, c) = [int(i) for i in input().split()]
tmp = [-1, 0, 1]
while tmp[0] <= a and tmp[1] <= b and (tmp[2] <= c):
	tmp = [i + 1 for i in tmp]
print(sum(tmp) - 3)


(y, b, r) = input().split()
y = int(y)
b = int(b)
r = int(r)
if b > y and r > y + 1:
	x = y + 1
	z = x + 1
	print(x + y + z)
elif r < b and b < y or (r < b and y < b) or (b > y and r <= y + 1) or (y == b and r == b) or (y > b and b == r) or (y == r and b > y) or (y == b and r < b) or (y < b and b == r):
	x = r - 1
	z = x - 1
	print(x + z + r)
elif b < r and b < y or (r > b and y == b) or (y == r and b < y):
	x = b - 1
	z = b + 1
	print(x + z + b)


a = list(map(int, input().split()))
print(3 * min(a[0] + 1, a[1], a[2] - 1))


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

def si():
	return input()

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

def msi():
	return map(str, input().strip().split(' '))

def li():
	return list(mi())
(a, b, c) = mi()
b -= 1
c -= 2
m = min(a, b)
m = min(m, c)
m = min(m, a)
print(3 * m + 3)


(x, y, z) = list(map(int, input().split(' ')))
ans = min(x, y - 1)
ans = min(ans, z - 2)
ans = ans * 3 + 3
print('{}'.format(ans))


from sys import stdin, stdout
from math import sin, tan, cos, pi, atan2, sqrt, acos, atan, factorial
from random import randint
(a, b, c) = map(int, stdin.readline().split())
ans = 0
for i in range(1, a + 1):
	if i + 1 <= b and i + 2 <= c:
		ans = i * 3 + 3
stdout.write(str(ans))


(y, b, r) = map(int, input().split())
i = 1
while i <= 100:
	if i + 1 <= y and i + 2 <= b and (i + 3 <= r):
		i += 1
	else:
		break
print(i + i + 1 + i + 2)


a = list(map(int, input().split()))
Y = a[0]
B = a[1]
R = a[2]
x = 1
y = 2
z = 3
while z < R and y < B and (x < Y):
	x = x + 1
	y = x + 1
	z = y + 1
print(x + y + z)


import math
(a, b, c) = map(int, input().split())
d = min(a, b - 1, c - 2)
if d == c - 2:
	print(3 * c - 3)
elif d == b - 1:
	print(3 * b)
else:
	print(3 * a + 3)


(y, b, r) = map(int, input().split())
if y >= b:
	y = b - 1
else:
	y = y
if r < b:
	b = r - 1
else:
	b = b
if y < r:
	if r == y + 1:
		y = r - 2
else:
	y = r - 2
b = y + 1
r = b + 1
while b == y + 1 and r == b + 1:
	print(y + b + r)
	break


arr = list(map(int, input().split()))
k = arr[1]
while True:
	if k - 1 <= arr[0] and k + 1 <= arr[2]:
		print(k * 3)
		break
	else:
		k -= 1


(y, b, r) = map(int, input().split())
ans = 0
f = 0
if b > y and r > y + 1:
	ans = max(ans, 3 * y + 3)
	f = 1
if y >= b - 1 and r > b:
	ans = max(ans, 3 * b)
	f = 1
if b >= r - 1 and y >= r - 2:
	ans = max(ans, 3 * r - 3)
print(ans)


a = map(int, input().split())
b = min(map(lambda z: z[1] + 1 - z[0], enumerate(a)))
print(3 * b)


z = input
(a, b, c) = list(map(int, z().split()))
for i in range(a, 0, -1):
	for j in range(b, 0, -1):
		for k in range(c, 0, -1):
			if i < j and j < k:
				print(i + i + i + 3)
				exit(0)


(y, b, r) = map(int, input().split())
m = min(y, b - 1, r - 2)
total = 3 * m + 3
print(total)


e = list(map(int, input().split()))
s = min(e)
q = 0
for i in range(0, 3):
	if e[i] == s:
		q += i
if q == 0:
	if e[2] == s + 1:
		print(s - 1 + s + s + 1)
	else:
		print(s + s + 1 + s + 2)
elif q == 1:
	print(s - 1 + s + s + 1)
else:
	print(s - 2 + s - 1 + s)


(a, b, c) = input().split()
a = int(a)
b = int(b)
c = int(c)
while c >= 3:
	if b >= c - 1 and a >= c - 2:
		print(c + c - 1 + c - 2)
		break
	c = c - 1


(l, m, n) = map(int, input().split())
y = b = r = 0
if l <= m and l <= n:
	y = l
	b = l + 1
	r = l + 2
elif m <= l and m <= n:
	y = m - 1
	b = m
	r = m + 1
else:
	y = n - 2
	b = n - 1
	r = n
while 1:
	if y <= l and b <= m and (r <= n):
		print(3 * b)
		break
	else:
		y -= 1
		b -= 1
		r -= 1


def solve(y, b, r):
	maxi = 0
	for i in range(1, y + 1):
		if i + 1 <= b and i + 2 <= r:
			maxi = max(i, maxi)
	return maxi * 3 + 3

def main():
	(y, b, r) = list(map(int, input().split()))
	print(solve(y, b, r))
main()


TN = 1

def solution():
	(y, b, r) = map(int, input().split())
	print(3 * min(y, b - 1, r - 2) + 3)
while TN != 0:
	solution()
	TN -= 1


def cal(a1, b1):
	if a1 > b1:
		a1 = b1 - 1
	elif a1 < b1:
		b1 = a1 + 1
	else:
		a1 -= 1
	return (a1, b1)
(a, b, c) = map(int, input().split())
(a1, b1) = cal(a, b)
if b1 > c:
	d = b1 - c + 1
	print(a1 - d + b1 - d + c)
elif b1 < c:
	print(a1 + b1 + b1 + 1)
else:
	print(a1 + b1 + c - 2)


(y, b, r) = input().split()
y = int(y)
b = int(b)
r = int(r)
x = 0
while True:
	if y + 1 <= b and y + 2 <= r:
		x = y * 3 + 3
		print(x)
		break
	else:
		y -= 1


print(3 + 3 * min(map(lambda item: int(item[1]) - item[0], enumerate(input().split()))))


from math import *
from cmath import *
from itertools import *
from decimal import *
from fractions import *
from sys import *
from types import CodeType, new_class
(n, m, k) = map(int, input().split())
print(min(n, m - 1, k - 2) * 3 + 3)


a = input().split()
z = []
for i in a:
	z.append(int(i))
z[1] -= 1
z[2] -= 2
print(min(z) * 3 + 3)


(y, b, r) = map(int, input().split())
l = 0
m = l + 1
n = m + 1
while l != y and m != b and (n != r):
	l += 1
	m += 1
	n += 1
summ = l + m + n
print(summ)


(a, b, c) = map(int, input().split())
if b >= a + 1:
	b = a + 1
else:
	a = b - 1
if c >= b + 1:
	c = b + 1
else:
	b = c - 1
if b >= a + 1:
	b = a + 1
else:
	a = b - 1
if c >= b + 1:
	c = b + 1
else:
	b = c - 1
print(a + b + c)


print(min((c - i for (i, c) in enumerate(map(int, input().split()), -1))) * 3)


ybr = input()
list1 = ybr.split()
y = int(list1[0])
b = int(list1[1])
r = int(list1[2])
mini = min(y, b, r)
if mini == r:
	print(r + (r - 1) + (r - 2))
elif mini == b:
	print(b + (b + 1) + (b - 1))
elif y + 1 == r:
	print(y - 1 + y + (y + 1))
else:
	print(y + (y + 1) + (y + 2))


def color():
	(y, b, r) = map(int, input().split())
	i = 1
	j = 2
	k = 3
	sum = i + j + k
	while i != y and b != j and (k != r):
		i = i + 1
		j = j + 1
		k = k + 1
		sum = i + j + k
	return sum
print(color())


(a, b, c) = map(int, input().split())

def abc(a, b, c):
	while True:
		if b >= a + 1 and c >= a + 2:
			return 3 * a + 3
		else:
			a -= 1
print(abc(a, b, c))


(y, b, r) = map(int, input().strip().split())
for i in range(y):
	if b >= y + 1:
		break
	else:
		y -= 1
b = y + 1
for j in range(b):
	if r >= b + 1:
		break
	else:
		b -= 1
r = b + 1
y = r - 2
summa = r + b + y
print(summa)


(q, w, e) = map(int, input().split())
print(min(q * 3 + 3, w * 3, e * 3 - 3))


(y, b, r) = input().split()
y = int(y)
b = int(b)
r = int(r)
a = min(y, b, r)
if r == a:
	print(3 * r - 3)
elif b == a:
	print(3 * b)
elif y == a:
	if r > b:
		print(3 * y + 3)
	elif r >= y + 2:
		print(3 * y + 3)
	else:
		print(3 * y)


y_b_r = list(map(int, input().rstrip().split()))
(y, b, r) = (y_b_r[0], y_b_r[1], y_b_r[2])
if r - 1 <= b:
	if r - 2 <= y:
		print(r + (r - 1) + (r - 2))
	elif r - 2 > y:
		print(y + 2 + (y + 1) + y)
elif r - 1 > b:
	if b - 1 <= y:
		print(b + 1 + b + (b - 1))
	elif b - 1 > y:
		print(y + 2 + (y + 1) + y)


n = 3
f = 100
x = list(map(int, input().split()))
for i in range(n):
	l = x[i] - i
	if l < f:
		f = l
s = f * 3 + 3
print(s)


import sys
(y, b, r) = list(map(int, input().split()))
for i in range(1, r + 1):
	(ys, bs, rs) = (i, i + 1, i + 2)
	if ys > y or bs > b or rs > r:
		break
	sol = ys + bs + rs
print(sol)
sys.stdout.flush()


(y, b, r) = list(map(int, input().split()))
val = 0
if r <= b and r <= y:
	val = r + (r - 1) + (r - 2)
elif b <= r and b <= y:
	if r > b:
		val = b + b + 1 + b - 1
	else:
		val = b - 1 + b + b - 2
elif r == y + 1:
	val = y - 1 + y + y + 1
else:
	val = y + y + 1 + y + 2
print(val)


from sys import stdin
(y, b, r) = map(int, stdin.readline().strip().split())
for i in range(110, 2, -1):
	if r >= i and b >= i - 1 and (y >= i - 2):
		print(i + i + i - 3)
		break


(y, b, r) = map(int, input().split())
sum = 0
while True:
	if b >= y + 1 and r >= y + 2:
		sum = y + y + 1 + y + 2
		break
	else:
		y = y - 1
print(sum)


(y, b, r) = map(int, input().split())
arr = [y, b, r]

def findMinPosition(arr):
	minP = 0
	for i in range(1, 2):
		if arr[minP] > arr[i]:
			minP = i
	return minP
minP = findMinPosition(arr)
output = 0
if minP == 0:
	n = arr[0]
	while n > 0:
		if n + 1 <= arr[1] and n + 2 <= arr[2]:
			output = 3 * n + 3
			break
		n -= 1
elif minP == 1:
	n = arr[1]
	while n > 0:
		if n - 1 <= arr[0] and n + 1 <= arr[2]:
			output = 3 * n
			break
		n -= 1
else:
	n = arr[2]
	while n > 0:
		if n - 1 <= arr[1] and n - 2 <= arr[0]:
			output = 3 * n - 3
			break
		n -= 1
print(output)


(y, b, r) = input().split()
(y, b, r) = (int(y), int(b), int(r))
if y == b == r:
	print(y + y - 1 + y - 2)
elif min(y, b, r) == y:
	if b - y >= 1 and r - y >= 2:
		print(y + y + 1 + y + 2)
	elif b - y >= 1 and r - y == 1:
		print(y - 1 + y + 1 + y)
	elif y == b and r - y >= 2:
		print(y - 1 + y + y + 1)
	elif y == r and b - r >= 1:
		print(y - 2 + y - 1 + y)
elif min(y, b, r) == b:
	if b != r:
		print(b - 1 + b + b + 1)
	elif b == r:
		print(b + b - 1 + b - 2)
elif min(y, b, r) == r:
	print(r + r - 1 + r - 2)


def main():
	(y, b, r) = map(int, input().split())
	mn = min(r - 2, b - 1, y)
	if mn < 0:
		print(0)
	else:
		print(mn * 3 + 3)
main()


(Ornament_Yellow, Ornament_Blue, Ornament_Red) = input().split()
Ornament_Yellow = int(Ornament_Yellow)
Ornament_Blue = int(Ornament_Blue)
Ornament_Red = int(Ornament_Red)
ans_Yellow = Ornament_Yellow
ans_Blue = Ornament_Blue
ans_Red = Ornament_Red
if Ornament_Blue >= Ornament_Red:
	ans_Blue = Ornament_Red - 1
else:
	ans_Red = Ornament_Blue + 1
if Ornament_Yellow >= ans_Blue:
	ans_Yellow = ans_Blue - 1
else:
	ans_Blue = Ornament_Yellow + 1
	ans_Red = ans_Blue + 1
answer = ans_Blue + ans_Red + ans_Yellow
print(answer)


s = 0
(a, b, c) = map(int, input().split())
for i in range(1, 99):
	if a >= i and b >= i + 1 and (c >= i + 2):
		s = i + i + 1 + i + 2
	else:
		break
print(s)


(a, b, c) = map(int, input().split())
x = min(a, b, c)
if x == c:
	print(c * 3 - 3)
elif x == b and a >= b - 1:
	print(b * 3)
elif x == a:
	if b >= a + 1 and c >= a + 2:
		print(a * 3 + 3)
	else:
		print(c * 3 - 3)


strings = input()
number = []
number = strings.split(' ')
for i in range(len(number)):
	number[i] = int(number[i]) - i
index = number.index(min(number))
if index == 0:
	print(number[index] * 3 + 3)
elif index == 1:
	print((number[index] + 1) * 3)
elif index == 2:
	print((number[index] + 2) * 3 - 3)


l = list(map(int, input().split()))
(y, b, r) = (l[0], l[1], l[2])
if b <= y:
	y2 = b
	y1 = b - 1
	if r <= y2:
		y3 = r
		y2 = r - 1
		y1 = r - 2
	else:
		y3 = b + 1
else:
	y1 = y
	y2 = y + 1
	if r <= y2:
		y3 = r
		y2 = r - 1
		y1 = r - 2
	else:
		y3 = y + 2
print(y1 + y2 + y3)


(y, b, r) = input().split()
y = int(y)
b = int(b)
r = int(r)
if r - b <= 1:
	b = r - 1
	if b - y <= 1:
		print(3 * (r - 1))
	else:
		print(3 * (y + 1))
else:
	r = b + 1
	if b - y <= 1:
		print(3 * (r - 1))
	else:
		print(3 * (y + 1))


import math
(a, b, c) = map(int, input().strip().split())
x = min(a, b - 1, c - 2)
e = x + x + 1 + x + 2
print(e)


(y, b, r) = input().split()
y = int(y)
b = int(b)
r = int(r)
potY = 1
potB = 2
potR = 3
while potY < y and potB < b and (potR < r):
	potY += 1
	potB += 1
	potR += 1
print(potY + potB + potR)


(x, y, z) = map(int, input().split())
if x + 1 <= y and x + 2 <= z:
	print(x + x + 1 + x + 2)
elif y - 1 <= x and y + 1 <= z:
	print(3 * y)
else:
	print(z - 1 + z - 2 + z)


(y, b, r) = [int(i) for i in input().split()]
min = y
if b <= min:
	min = b
if r <= min:
	min = r
if min == b and min == r:
	min = r
if min == b and min != r:
	print(3 * b)
elif min == r:
	print(3 * r - 3)
elif b - r != 0 and r > b:
	print(3 * y + 3)
elif b - r != 0 and b > r:
	if r - y != 1:
		print(3 * y + 3)
	elif r - y == 1:
		print(3 * r - 3)
elif b - r == 0 and r - y != 1:
	print(3 * y + 3)
elif b - r == 0 and r - y == 1:
	print(3 * r - 3)


a = input().split()
y = int(a[0])
b = int(a[1])
r = int(a[2])
d = y
e = b - 1
f = r - 2
g = min(d, e, f)
print(g * 3 + 3)


class Tree:

	def solve(self, y, b, r):
		ans = 0
		if b >= y + 1 and r >= y + 2:
			ans = 3 * y + 3
		if y >= b - 1 and r >= b + 1:
			ans = max(ans, 3 * b)
		if y >= r - 2 and b >= r - 1:
			ans = max(ans, 3 * r - 3)
		print(ans)
(y, b, r) = map(int, input().split())
A = Tree()
A.solve(y, b, r)


(y, b, r) = map(int, input().split())
l = []
s = 0
pick = y
while 1:
	if b >= pick + 1 and r >= pick + 2:
		s = 3 * pick + 3
		break
	else:
		pick -= 1
print(s)


import math
(yellow, blue, red) = input().split(' ')
yellow = int(yellow)
blue = int(blue)
red = int(red)
y = 1
b = 2
r = 3
while y < yellow and b < blue and (r < red):
	y += 1
	b += 1
	r += 1
total = y + b + r
print(total, end='')


(y, b, r) = input().split()
Y = int(y)
B = int(b)
R = int(r)
small = min(Y, B - 1, R - 2)
cnt = 3 * small + 3
print(cnt)


s = input()
s = s.split(' ')
for i in range(3):
	s[i] = int(s[i])
mini = s[0]
minindex = 0
result = 0
for i in range(1, 3):
	if s[i] <= mini:
		mini = s[i]
		minindex = i
if minindex == 0:
	if s[2] > s[0] + 1:
		result = 3 * s[0] + 3
	else:
		result = 3 * (s[0] - 1) + 3
elif minindex == 1:
	result = 3 * s[1]
elif minindex == 2:
	result = 3 * s[2] - 3
print(result)


a = list(map(int, input().split()))
for i in range(3):
	a[i] -= i
print(min(a) * 3 + 3)


(a, b, c) = map(int, input().split())

def check(aa, bb, cc):
	if aa <= a and bb <= b and (cc <= c):
		return 1
	else:
		return 0
for x in range(100, -1, -1):
	if check(x, x + 1, x + 2):
		print(x * 3 + 3)
		break


(y, b, r) = [int(item) for item in input().split()]
m = -1
for i in range(y + 1):
	j = i + 1
	k = j + 1
	if j <= b and k <= r:
		m = max(m, i + j + k)
print(m)


(y, b, r) = map(int, input().split())
ans = 0
for i in range(1, y + 1):
	if i + 1 <= b and i + 2 <= r:
		ans = max(ans, i + i + 1 + i + 2)
	else:
		break
print(ans)


vr = ''
q = 0
it = 0
s = input()
s = s + ' '
while it < 3:
	while s[q] != ' ':
		vr = vr + s[q]
		q = q + 1
	else:
		q = q + 1
		it = it + 1
		if it == 1:
			a = int(vr)
		elif it == 2:
			b = int(vr)
		else:
			c = int(vr)
		vr = ''
a = a + 1
c = c - 1
v = min(a, b, c) * 3
print(v)


(y, b, r) = list(map(int, input().split()))
max = 0
if y + 1 <= b and y + 2 <= r and (y + y + 1 + y + 2 > max):
	max = y + y + 1 + y + 2
if b - 1 <= y and b + 1 <= r and (b - 1 + b + b + 1 > max):
	max = b - 1 + b + b + 1
if r - 2 <= y and r - 1 <= b and (r - 2 + r - 1 + r > max):
	max = r - 2 + r - 1 + r
print('{:d}'.format(max))


def solve(y, b, r):
	ans = 0
	(tempy, tempb, tempr) = (1, 2, 3)
	while tempy < tempb < tempr and (tempy <= y and tempb <= b and (tempr <= r)):
		tempy += 1
		tempb = tempy + 1
		tempr = tempb + 1
	print(tempy + tempb + tempr - 3)

def main():
	(y, b, r) = map(int, input().split())
	solve(y, b, r)
main()


(y, b, r) = input().split()
y = int(y)
b = int(b)
r = int(r)
rv = 3
bv = 2
yv = 1
while rv < r and bv < b and (yv < y):
	rv = rv + 1
	bv = bv + 1
	yv = yv + 1
print(rv + bv + yv)


class Solution(object):

	def solve(self):
		(y, b, r) = map(int, input().strip().split(' '))
		for _y in range(y, 0, -1):
			if _y + 1 <= b and _y + 2 <= r:
				return _y * 3 + 3
sol = Solution()
print(sol.solve())


(y, b, r) = map(int, input().split())
xr = r
xb = xr - 1
xy = xb - 1
if xb > b:
	xr = xr - (xb - b)
	xy = xy - (xb - b)
	xb = b
if xy > y:
	xr = xr - (xy - y)
	xb = xb - (xy - y)
	xy = y
print(xy + xb + xr)


(y, b, r) = list(map(int, input().split()))
c = 1
while True:
	if b > c + 1 and r > c + 2 and (y > c):
		c = c + 1
	else:
		break
print(c + c + 1 + c + 2)


(y, b, r) = [int(i) for i in input().split()]
x = 0
while x < y and x + 1 < b and (x + 2 < r):
	x += 1
print(x * 3 + 3)


(y, b, r) = map(int, input().split())
z = 0
while r >= 3:
	if b >= r - 1 and y >= r - 2:
		b = r - 1
		y = b - 1
		z = 1
		x = r + y + b
		print(x)
		break
	else:
		r = r - 1
if z == 0:
	print(6)


(y, b, r) = map(int, input().split())
ok = False
while ok == False:
	if r > b + 1:
		r -= 1
	if b >= r:
		b -= 1
	if b > y + 1:
		b -= 1
	if y >= b:
		y -= 1
	if y + 1 == b and b + 1 == r:
		ok = True
print(3 * y + 3)


import sys
inf = float('inf')
abc = 'abcdefghijklmnopqrstuvwxyz'
abd = {'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
(mod, MOD) = (1000000007, 998244353)
vow = ['a', 'e', 'i', 'o', 'u']
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

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

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

def input():
	return sys.stdin.readline().strip()
(y, b, r) = get_ints()
mini = min(y, b, r)
(yi, bi, ri) = (0, 1, 2)
for i in range(mini):
	yi += 1
	ri += 1
	bi += 1
	if yi == y or ri == r or bi == b:
		break
print(yi + ri + bi)


(y, b, r) = [int(i) for i in input().split()]
potential = 0
if y + 1 <= b and y + 2 <= r:
	potential = max(potential, 3 * (y + 1))
if b - 1 <= y and b + 1 <= r:
	potential = max(potential, 3 * b)
if r - 2 <= y and r - 1 <= b:
	potential = max(potential, 3 * (r - 1))
print(potential)


(y, b, r) = [int(c) for c in input().split()]
while True:
	if y < b and y < r - 1:
		print(3 * (y + 1))
		break
	y -= 1


(i, j, k) = map(int, input().split())
res = 0
if j > i and k > i + 1:
	res = max(res, i * 3 + 3)
if i > j - 2 and k > j:
	res = max(res, j * 3)
if i > k - 3 and j > k - 2:
	res = max(res, k * 3 - 3)
print(res)


from sys import stdin
(y, b, r) = map(int, stdin.readline().rstrip().split(' '))
m = 6
for i in range(2, 99):
	if y >= i and b >= i + 1 and (r >= i + 2):
		m = 3 * i + 3
print(m)


l = list(map(int, input().split()))
m = min(l)
if l[-1] == m:
	print((m - 1) * 3)
elif l[-2] == m:
	print(m * 3)
elif l[-1] >= l[0] + 2:
	print((m + 1) * 3)
else:
	print((l[-1] - 1) * 3)


def main():
	list_of_obj = [int(i) for i in input().split()]
	yellow = list_of_obj[0]
	blue = list_of_obj[1]
	red = list_of_obj[2]
	for i in range(red, 0, -1):
		if yellow >= i - 2 and blue >= i - 1:
			print(3 * i - 3)
			break
main()


(y, b, r) = map(int, input().split())
a = min(y, b, r)
if a <= y and a + 1 <= b and (a + 2 <= r):
	print(a * 3 + 3)
	exit()
if a - 1 <= y and a <= b and (a + 1 <= r):
	print((a - 1) * 3 + 3)
	exit()
if a - 2 <= y and a - 1 <= b and (a <= r):
	print((a - 2) * 3 + 3)
	exit()


[y, b, r] = [int(x) for x in input().split(' ')]
maxY = 1
maxB = 2
maxR = 3
for i in range(1, y + 1):
	if b - i >= 1 and r - i >= 2:
		(maxY, maxB, maxR) = (i, i + 1, i + 2)
	else:
		break
print(sum([maxY, maxB, maxR]))


tmp = input().split()
for i in range(3):
	tmp[i] = int(tmp[i])
mins = min(tmp[0], min(tmp[1] - 1, tmp[2] - 2))
print(int(3 * (mins + 1)))


a = list(map(int, input().split()))
b = max(a)
j = []
for i in range(b):
	k = [i, i + 1, i + 2]
	if a[0] >= k[0] and a[1] >= k[1] and (a[2] >= k[2]):
		j.append(k)
print(sum(j[-1]))


import sys
l = list(reversed([int(e) for e in input().strip().split()]))
sol = 0
while True:
	idx = l.index(max(l))
	if idx == 0 and l[1] >= l[0] - 1 and (l[2] >= l[0] - 2):
		sol = 3 * l[0] - 3
		break
	elif idx == 1 and l[0] >= l[1] + 1 and (l[2] >= l[1] - 1):
		sol = 3 * l[1]
		break
	elif idx == 2 and l[0] >= l[2] + 2 and (l[1] >= l[2] + 1):
		sol = 3 * l[2] + 3
		break
	else:
		l[idx] -= 1
print(sol)
sys.stdout.flush()


(y, b, r) = input().split()
y = int(y)
b = int(b)
r = int(r)
if b == r:
	if y < b:
		if y + 2 <= r:
			z = 3 * y + 3
			print(z)
		else:
			z = 3 * y
			print(z)
	elif y >= b:
		z = 3 * r - 3
		print(z)
elif b < r:
	if y < b:
		if y + 2 <= r:
			z = 3 * y + 3
			print(z)
		else:
			z = 3 * y
			print(z)
	elif y == b or y >= r:
		z = 3 * b
		print(z)
	elif b < y and y < r:
		z = 3 * b
		print(z)
elif b > r:
	if y >= b or y == r:
		if r - 2 <= y:
			z = 3 * r - 3
			print(z)
		else:
			z = 3 * r
			print(z)
	elif y < r:
		if y + 2 <= r:
			z = 3 * y + 3
			print(z)
		else:
			z = 3 * y
			print(z)
	elif r < y and y < b:
		z = 3 * r - 3
		print(z)


a = input().split(' ')
y = int(a[0])
b = int(a[1])
r = int(a[2])
for i in range(2):
	if y >= b:
		y = b - 1
	if r > b:
		r = b + 1
	if b >= r:
		b = r - 1
	if b > y:
		b = y + 1
print(y + b + r)


(y, b, r) = [int(c) for c in input().split()]
x = min(y, b, r)
if x == y:
	while 1:
		if b >= y + 1 and r >= y + 2:
			b = y + 1
			r = y + 2
			break
		else:
			y = y - 1
elif x == b:
	while 1:
		if r >= b + 1:
			y = b - 1
			r = b + 1
			break
		else:
			b = b - 1
elif x == r:
	b = r - 1
	y = b - 1
print(y + b + r)


(y, b, r) = map(int, input().split())
res = 6
y -= 1
b -= 2
r -= 3
while y * b * r:
	res += 3
	y -= 1
	b -= 1
	r -= 1
print(res)


import math
import os
import random
import re
import sys

def ProblemA(a, b, c):
	if b >= a + 1 and c >= a + 2:
		return 3 * a + 3
	elif a >= b - 1 and c >= b + 1:
		return 3 * b
	elif a >= c - 2 and b >= c - 1:
		return 3 * c - 3
l = list(map(int, input().rstrip().split()))
a = l[0]
b = l[1]
c = l[2]
print(ProblemA(a, b, c))


l = list(map(int, input().split()))
if l[1] >= l[2] - 1 and l[0] >= l[2] - 2:
	print(3 * (l[2] - 1))
else:
	mini = min(l)
	if mini == l[2]:
		print(3 * (mini - 1))
	elif mini == l[1]:
		print(3 * mini)
	else:
		print(3 * (mini + 1))


(y, b, r) = map(int, input().split())
k = 0
if y <= b - 1 and y <= r - 2:
	k = y * 3 + 3
elif b - 1 <= y and b - 1 <= r - 2:
	k = b * 3
elif r - 2 <= y and r - 2 <= b - 1:
	k = r * 3 - 3
print(k)


l = list(map(int, input().split()))
i = l.index(min(l))
for j in range(len(l)):
	if l[j] == l[i]:
		i = j
if i == 0:
	if l[i] + 1 <= l[i + 1] and l[i] + 2 <= l[i + 2]:
		print(3 * l[i] + 3)
	elif l[i] + 2 > l[i + 2]:
		print(3 * l[i + 2] - 3)
elif i == 1:
	if l[i] - 1 <= l[i - 1] and l[i] + 1 <= l[i + 1]:
		print(3 * l[i])
elif l[i] - 2 <= l[i - 2] and l[i] - 1 <= l[i - 1]:
	print(3 * l[i] - 3)


(y, b, r) = (int(s) for s in input().split())
m = min(y, b, r)
ans = 0
if m == r:
	ans = 3 * r - 3
elif m == b:
	if b < r:
		ans = 3 * b
elif y == r - 1:
	ans = 3 * r - 3
else:
	ans = 3 * y + 3
print(ans)


(y, b, r) = tuple(map(int, input().split()))
if min(r, min(b, y)) == r:
	print(3 * r - 3)
elif min(r, min(b, y)) == b:
	print(3 * b)
else:
	while y + 2 > r:
		y -= 1
	print(3 * y + 3)


(y, b, r) = map(int, input().split())
d = b - 1
f = r - 2
g = min(y, d, f)
l = [g, g + 1, g + 2]
k = sum(l)
print(k)


(y, b, r) = map(int, input().split())
b = b - 1
t = min(b, y)
r = r - 2
re = min(t, r)
print(re + re + 1 + re + 2)


(y, b, r) = map(int, input().split())
l = 1
m = 2
n = 3
sum = 0
if y >= b and y >= r:
	k = y
elif b >= r:
	k = b
else:
	k = r
for i in range(k):
	if y > l and b > m and (r > n):
		l = l + 1
		m = m + 1
		n = n + 1
print(l + m + n)


def read():
	return int(input())

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

def readmap():
	return map(int, input().split())
(y, b, r) = readmap()
b -= 1
r -= 2
print(3 * min(y, b, r) + 3)


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

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

def read_string():
	return input().strip()

def read_string_list(delim=' '):
	return input().strip().split(delim)
import sys
import math
[y, b, r] = read_int_list()
least = 1
for i in range(1, y + 1):
	if i + 1 <= b and i + 2 <= r:
		least = i
print(3 * least + 3)


(a, b, c) = map(int, input().split())
(x, y, z) = (1, 2, 3)
while a > x and b > y and (c > z):
	x += 1
	y += 1
	z += 1
print(x + y + z)


R = lambda : map(int, input().split())
(y, b, r) = R()
mi = min(y, b, r)
if mi == y:
	if mi == r:
		print(r - 2 + r - 1 + r)
	elif mi == b:
		print(b - 1 + b + b + 1)
	elif mi + 2 > r:
		print(r - 2 + r - 1 + r)
	else:
		print(y + y + 1 + y + 2)
elif mi == b:
	if mi == r:
		print(r - 2 + r - 1 + r)
	else:
		print(mi - 1 + mi + mi + 1)
elif mi == r:
	print(mi - 2 + mi - 1 + mi)


arr = list(map(int, input().split()))
arr2 = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]
arr2[0][0] = arr[0]
arr2[0][1] = arr[0] + 1
arr2[0][2] = arr[0] + 2
arr2[1][0] = arr[1] - 1
arr2[1][1] = arr[1]
arr2[1][2] = arr[1] + 1
arr2[2][0] = arr[2] - 2
arr2[2][1] = arr[2] - 1
arr2[2][2] = arr[2]
if arr2[0][0] <= arr[0] and arr2[0][1] <= arr[1] and (arr2[0][2] <= arr[2]):
	print(arr2[0][0] + arr2[0][1] + arr2[0][2])
elif arr2[1][0] <= arr[0] and arr2[1][1] <= arr[1] and (arr2[1][2] <= arr[2]):
	print(arr2[1][0] + arr2[1][1] + arr2[1][2])
elif arr2[2][0] <= arr[0] and arr2[2][1] <= arr[1] and (arr2[2][2] <= arr[2]):
	print(arr2[2][0] + arr2[2][1] + arr2[2][2])


import sys, os
from io import BytesIO, IOBase
import collections, itertools, bisect, heapq, math, string
from decimal import *
BUFSIZE = 8192
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

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

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

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

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

class IOWrapper(IOBase):

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

def main():
	(y, b, r) = map(int, input().split())
	(i, j, k) = (1, 2, 3)
	ans = 0
	while i <= y and j <= b and (k <= r):
		ans = max(ans, i + j + k)
		i += 1
		j += 1
		k += 1
	print(ans)
main()


list1 = input().split()
f = 0
(y, b, r) = (int(list1[0]), int(list1[1]), int(list1[2]))
A = min(y, b - 1, r - 2)
if A == y:
	f = y * 3 + 3
elif A == b - 1:
	f = b * 3
elif A == r - 2:
	f = r * 3 - 3
print(f)


def christmas(orn):
	(y, b, r) = (orn[0], orn[1], orn[2])
	for i in range(y, 0, -1):
		if b >= i + 1 and r >= i + 2:
			return 3 * i + 3
oo = list(map(int, input().split()))
print(christmas(oo))


inp = input()
ornam = inp.split()
y = int(ornam[0])
b = int(ornam[1])
r = int(ornam[2])
m = min(y, b, r)
if m == r:
	print(3 * r - 3)
elif m == b:
	print(3 * b)
else:
	if y + 2 > r:
		y = r - 2
	print(3 * y + 3)


(y, b, r) = map(int, input().split())
maxi = -2 ** 31 - 1
while y > 0:
	if b - y > 0 and r - y - 1 > 0:
		maxi = max(maxi, y * 3 + 3)
		break
	else:
		y = y - 1
print(maxi)


N = list(map(int, input().split()))
if N[2] - N[1] == 0:
	N[1] -= 1
if N[2] - N[0] == 0:
	N[0] -= 2
if N[2] - N[0] == 1:
	N[0] -= 1
if N[1] - N[0] == 0:
	N[0] -= 1
minimum = 101
minindex = -1
for i in range(3):
	if N[i] < minimum:
		minimum = N[i]
		minindex = i
if minindex == 0:
	print((minimum + 1) * 3)
if minindex == 1:
	print(minimum * 3)
if minindex == 2:
	print((minimum - 1) * 3)


orns = input().split(' ')
for i in range(len(orns)):
	orns[i] = int(orns[i])
m = orns[0]
while m + 1 > orns[1] or m + 2 > orns[2]:
	m -= 1
print(m + m + 1 + m + 2)


a = list(map(int, input().split()))
cnt = a[0]
for i in range(1, 3):
	if a[i] > cnt:
		cnt += 1
	else:
		cnt = a[i]
print(3 * cnt - 3)


def retarray():
	return list(map(int, input().split()))
(y, b, r) = retarray()
f = True
while f:
	if y + 1 <= b and y + 2 <= r:
		f = False
	y -= 1
print(3 * (y + 1) + 3)


(y, b, r) = input().split(' ')
y = int(y)
b = int(b)
r = int(r)
s = min(y + 2, b + 1, r)
answer = s * 3 - 3
print(answer)


[y, b, r] = [int(j) for j in input().split(' ')]
if b >= r - 1 and y >= r - 2:
	print(3 * r - 3)
elif b < r - 1:
	if y >= b - 1:
		print(3 * b)
	else:
		print(3 * y + 3)
else:
	print(3 * y + 3)


arr = [int(i) for i in input().split()]
arr[1] = arr[1] - 1
arr[2] = arr[2] - 2
minima = min(arr)
print(minima * 3 + 3)


(y, b, r) = map(int, input().split())
max_pos = -1000000000.0
for i in range(max(y, b, r)):
	if i - 1 + i + i + 1 > max_pos and i - 1 <= y and (i <= b) and (i + 1 <= r):
		max_pos = i - 1 + i + i + 1
print(max_pos)


(y, b, r) = map(int, input().split())
for b_ in range(2, b + 1):
	if b_ - 1 < y and b_ + 1 < r:
		continue
	break
print(3 * b_)


inp = input().split(' ')
a = int(inp[0])
b = int(inp[1])
c = int(inp[2])
test = min(a + 1, b, c - 1)
print(test * 3)


(y, b, r) = list(map(int, input().split()))
a = 3 * r - 3
b = 3 * b
c = 3 * y + 3
print(min(a, b, c))


(yellow, blue, red) = input().split(' ')
yellow = int(yellow)
blue = int(blue)
red = int(red)
if red - 1 <= blue and red - 2 <= yellow:
	decoration = red - 2 + red - 1 + red
elif red - 1 > blue and blue - 1 < yellow:
	decoration = blue - 1 + blue + blue + 1
else:
	decoration = yellow + yellow + 1 + yellow + 2
print(decoration)


(y, b, r) = input().split()
y = int(y)
b = int(b)
r = int(r)
if y < b < r:
	print(y + y + 1 + y + 2)
if y > b < r and r != y:
	print(b - 1 + b + 1 + b)
if y < b > r and (r - 1 == y or y > r):
	print(r + r - 1 + r - 2)
if y == b == r:
	print(y + y - 1 + y - 2)
if y == b > r:
	print(r - 1 + r + r - 2)
if y == r > b:
	print(b - 1 + b + b + 1)
if y > b == r:
	print(b - 1 + b - 2 + b)
if y < b > r and y < r and (r - 1 != y):
	print(y + 2 + y + 1 + y)
if r == y < b:
	print(y - 1 + y - 2 + y)
if r == b > y and y + 1 != r:
	print(y + y + 1 + y + 2)
if y == b < r:
	print(y - 1 + y + y + 1)
if r == b > y and y + 1 == r:
	print(r + r + r - 1 - 2)


X = list(map(int, input().split()))
print(min(X[0], X[1] - 1, X[2] - 2) * 3 + 3)


(a, b, c) = input().split()
a = int(a)
b = int(b)
c = int(c)
x = min(a, b, c)
if c == x:
	print(3 * c - 3)
elif b == x:
	print(3 * b)
elif c < a + 2:
	print(3 * c - 3)
else:
	print(3 * a + 3)


input = input()
newarray = [int(i) for i in input.split()]
if newarray[0] >= newarray[2] - 2 and newarray[1] >= newarray[2] - 1:
	answer = (newarray[2] - 1) * 3
elif newarray[0] >= newarray[1] - 1 and newarray[2] >= newarray[1] + 1:
	answer = newarray[1] * 3
else:
	answer = (newarray[0] + 1) * 3
print(answer)


line = input()
numbers = [int(i) for i in line.split()]
(_min, argmin) = (float('inf'), None)
for (i, n) in enumerate(numbers):
	if n <= _min:
		(_min, argmin) = (n, i)
if argmin == 2:
	result = 3 * _min - 3
elif argmin == 1:
	result = 3 * _min
elif argmin == 0:
	if numbers[2] >= numbers[0] + 2:
		result = 3 * _min + 3
	else:
		result = 3 * (_min - 1) + 3
else:
	result = 'Invalid input'
print(result)


(y, b, r) = map(int, input().split())
x = min(y, b, r)
if r == x:
	d = 3 * r - 3
elif b == x and r != x:
	d = 3 * b
elif r - y >= 2:
	d = 3 * y + 3
elif r - y == 1:
	d = 3 * y
print(d)


(y, b, r) = map(int, input().split())
xx = r - 1
yy = r - 2
if y >= yy and b >= xx:
	print(xx + yy + r)
	exit()
if y < yy and b >= xx:
	print(y + y + 1 + y + 2)
	exit()
if b < xx and y >= yy:
	print(3 * b)
	exit()
if b < xx and y < yy:
	if b <= y:
		print(3 * b)
		exit()
	else:
		print(3 * y + 3)
		exit()


def out(x):
	print(x)
	exit(0)
n = input().split(' ')
for i in range(len(n)):
	n[i] = int(n[i])
(yellow, blue, red) = (n[0], n[1], n[2])
n.sort()
if yellow < blue < red:
	output = 3 * yellow + 3
	out(output)
if yellow < blue and red > yellow + 1:
	output = 3 * yellow + 3
	out(output)
if n[0] == yellow and red == yellow:
	output = 3 * yellow - 3
	out(output)
elif n[0] == yellow and blue == yellow:
	output = 3 * yellow
	out(output)
elif n[0] == yellow and red == yellow + 1:
	output = 3 * yellow
	out(output)
elif n[0] == blue and red == blue:
	output = red * 3 - 3
	out(output)
elif n[0] == blue and red > blue:
	output = 3 * blue
	out(output)
elif n[0] == red:
	output = red * 3 - 3
	out(output)


from sys import stdin, stdout
(y, b, r) = [int(x) for x in stdin.readline().split()]
ans = 0
if r - 1 <= b and r - 2 <= y:
	ans = r
elif b + 1 <= r and b - 1 <= y:
	ans = b + 1
else:
	ans = y + 2
ans = 3 * ans - 3
stdout.write(str(ans))


m = list(map(int, input().split()))
su = sum(m)
n = 1
check = 3 * n + 3
while check < su:
	n += 1
	if n > m[0] or n + 1 > m[1] or n + 2 > m[2]:
		break
	check = 3 * n + 3
print(check)


a = [int(x) for x in input().split()]
for i in range(a[0] + 1):
	if i + 1 >= a[1] or i + 2 >= a[2]:
		break
sum = i + i + 1 + i + 2
print(sum)


(y, b, r) = input().split()
y = int(y)
b = int(b)
r = int(r)
print(min(y, b - 1, r - 2) * 3 + 3)


(y, b, r) = map(int, input().split())
for i in range(1, y + 1):
	for j in range(1, b + 1):
		for k in range(1, r + 1):
			if k == j + 1 and j == i + 1:
				red = k
				blue = j
				yellow = i
print(red + blue + yellow)


def f(a, b, c):
	if a + 1 <= b and a + 2 <= c:
		return 3 * a + 3
	else:
		return f(a - 1, b, c)
(a, b, c) = map(int, input().split())
print(f(a, b, c))


(a, b, c) = map(int, input().split())
print(max(3 * a + 3 if a < b and a + 1 < c else 0, 3 * b if b - 2 < a and b < c else 0, 3 * c - 3 if c - 3 < a and c - 2 < b else 0))


l = list(map(int, input().split()))
l[1] -= 1
l[2] -= 2
a = min(l)
b = a + (a + 1) + (a + 2)
print(b)


import sys
(y, b, r) = input().split()
y = int(y)
b = int(b)
r = int(r)
for i in range(1, y + 1):
	if i + 1 <= b and i + 2 <= r:
		y1 = i + i + 1 + i + 2
print(y1)


(y, b, r) = map(int, input().split())
a = 0
bb = 0
c = 0
for i in range(y + 1):
	if i == 0:
		continue
	if i + 1 > b or i + 2 > r:
		break
	a = i
	bb = i + 1
	c = i + 2
print(a + bb + c)


(a, b, c) = map(int, input().split())
idx = [0, 1, 2]
l = [a, b - 1, c - 2]
d = [y for (x, y) in sorted(zip(l, idx))]
ans = l[d[0]] * 3 + 3
print(ans)


a = list(map(int, input().split()))
if min(a) == a[2] and max(a) == a[0]:
	print(3 * a[2] - 3)
elif min(a) == a[1] and max(a) == a[0]:
	print(3 * a[1])
elif min(a) == a[0] and max(a) == a[1]:
	if a[2] - a[0] == 2 or a[2] - a[0] > 2:
		print(3 * a[0] + 3)
	else:
		print(3 * a[2] - 3)
elif min(a) == a[2] and max(a) == a[1]:
	print(3 * a[2] - 3)
elif min(a) == a[1] and max(a) == a[2]:
	print(3 * a[1])
elif min(a) == a[0] and max(a) == a[2]:
	if a[2] - a[0] == 2 or a[2] - a[0] > 2:
		print(3 * a[0] + 3)
	else:
		print(3 * a[2] - 3)
elif a[0] == a[1] and a[1] == a[2]:
	print(3 * a[2] - 3)
elif a[0] == a[1] and a[1] > a[2]:
	print(3 * a[2] - 3)
elif a[0] == a[1] and a[1] < a[2]:
	print(3 * a[1])
elif a[1] == a[2] and a[0] < a[2]:
	print(3 * a[0] + 3)
elif a[1] == a[2] and a[0] > a[2]:
	print(3 * a[2] - 3)
elif a[0] == a[2] and a[1] > a[2]:
	print(3 * a[2] - 3)
elif a[0] == a[2] and a[1] < a[2]:
	print(3 * a[1])


(y, b, r) = map(int, input().split())
a = [y + 2, b + 1, r]
if len(set(a)) == 1:
	pass
elif min(a) == a[2]:
	(y, b) = (r - 2, r - 1)
elif min(a) == a[1]:
	(y, r) = (b - 1, b + 1)
else:
	(b, r) = (y + 1, y + 2)
print(y + b + r)


def max(l):
	y = l[0]
	b = y + 1
	r = b + 1
	if b <= l[1]:
		if r <= l[2]:
			print(y + b + r)
			return
		else:
			l[0] = l[0] - 1
			max(l)
	else:
		l[0] = l[0] - 1
		max(l)
l = [int(i) for i in input().split()]
max(l)


a = [int(x) for x in input().split()]
y = a[0]
b = a[1]
r = a[2]
miny = y
minb = b - 1
minr = r - 2
mn = min(miny, minb, minr)
ans = mn * 3 + 3
print(ans)


l = list(map(int, input().split()))
while 1:
	if l[1] - l[0] != 1:
		if l[0] >= l[1]:
			l[0] -= 1
		elif l[0] < l[1]:
			l[1] -= 1
	if l[2] - l[1] != 1:
		if l[1] >= l[2]:
			l[1] -= 1
		elif l[1] < l[2]:
			l[2] -= 1
	if l[1] - l[0] == 1:
		if l[2] - l[1] == 1:
			break
print(sum(l))


(a, b, c) = map(int, input().split())
m = min(a, b, c)
a = min(a, m)
b = min(b, m + 1)
c = min(c, m + 2)
for i in range(2):
	if a > b - 1:
		a = b - 1
	elif a < b - 1:
		b = a + 1
	if b > c - 1:
		b = c - 1
	if b < c - 1:
		c = b + 1
print(a + b + c)


(y, b, r) = map(int, input().split())
smallest = None
for i in [y, b, r]:
	if smallest == None:
		smallest = i
	elif smallest > i:
		smallest = i
if smallest == b != r:
	add = 3 * b
	print(add)
elif smallest == r or smallest == y == b == r:
	add = 3 * r - 3
	print(add)
elif y + 1 == r and smallest == y:
	add = 3 * r - 3
	print(add)
elif smallest == y != b:
	add = 3 * y + 3
	print(add)
quit()


(y, b, r) = map(int, input().split())
d1 = b - y
d2 = r - b
if d1 >= 1 and d2 >= 1 or (d1 >= 1 and d2 < 1 and (y < r - 2)):
	s = 3 * y + 3
elif d1 < 1 and d2 >= 1:
	s = 3 * b
elif d1 >= 1 and d2 < 1 and (y >= r - 2) or (d1 < 1 and d2 < 1):
	s = 3 * r - 3
print(s)


import math as mt
import itertools as it
import functools as ft
import random as rnd
stdin = lambda type_='int', sep=' ': list(map(eval(type_), input().split(sep)))
joint = lambda sep=' ', *args: sep.join((str(i) if type(i) != list else sep.join(map(str, i)) for i in args))
(y, b, r) = stdin()
(i, j, k) = (y, y + 1, y + 2)
if i <= y and j <= b and (k <= r):
	print(i + j + k)
	exit(0)
(i, j, k) = (b - 1, b, b + 1)
if i <= y and j <= b and (k <= r):
	print(i + j + k)
	exit(0)
(i, j, k) = (r - 2, r - 1, r)
if i <= y and j <= b and (k <= r):
	print(i + j + k)
	exit(0)


def read_input():
	ornaments = input()
	ornaments = [int(ornament) for ornament in ornaments.strip().split()]
	return ornaments

def find_max_ornaments(yellow, blue, red):
	min_yellow = min([yellow, blue - 1, red - 2])
	return min_yellow * 3 + 3
ornaments = read_input()
max_ornaments = find_max_ornaments(*ornaments)
print(max_ornaments)


ls = list(map(int, input('').split(' ')))
result = 0
ls.reverse()
mini = min(ls)
addr = ls.index(mini)
if addr == 0:
	print(mini * 3 - 3)
elif addr == 1:
	flag = 1
	while flag == 1:
		if ls[0] >= mini + 1:
			flag = 0
		else:
			mini -= 1
	print(mini * 3)
else:
	flag = 1
	while flag == 1:
		if ls[0] >= mini + 2 and ls[1] >= mini + 1:
			flag = 0
		else:
			mini -= 1
	print(mini * 3 + 3)


import sys

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

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

def input():
	return sys.stdin.readline().strip()
(y, b, r) = get_ints()
for i in range(r, 0, -1):
	if r - 1 <= b and r - 2 <= y:
		break
	else:
		r = r - 1
print(3 * r - 3)


ornS = [int(i) for i in input().split()]
min_ = min(ornS)
ans = 0
if min_ == ornS[2]:
	print(ornS[2] * 3 - 3)
elif min_ == ornS[0]:
	ans = 0
	k = ornS[0]
	while True:
		if ornS[0] + 2 <= ornS[2] and ornS[0] + 1 <= ornS[1]:
			ans = ornS[0] * 3 + 3
			break
		ornS[0] -= 1
	print(ans)
elif min_ == ornS[1]:
	ans = 0
	k = ornS[1]
	while True:
		if ornS[1] + 1 <= ornS[2] and ornS[1] - 1 <= ornS[0]:
			ans = ornS[1] * 3
			break
		ornS[1] -= 1
	print(ans)


(y, b, r) = [int(i) for i in input().split()]
oy = ob = or1 = 0
a = [y, b, r]
mm = a.index(min(a))
if mm == 2:
	or1 = r
	ob = r - 1
	oy = r - 2
elif mm == 1:
	if r >= b + 1:
		or1 = b + 1
		ob = b
		oy = b - 1
	else:
		or1 = b
		ob = b - 1
		oy = b - 2
elif b >= y + 1:
	if r >= y + 2:
		or1 = y + 2
		ob = y + 1
		oy = y
	elif r == y + 1:
		or1 = y + 1
		ob = y
		oy = y - 1
	else:
		or1 = y
		ob = y - 1
		oy = y - 2
elif r >= y + 1:
	or1 = y + 1
	ob = y
	oy = y - 1
else:
	or1 = y
	ob = y - 1
	oy = y - 2
print(oy + ob + or1)


import sys
import math
fileoperation = 0
if fileoperation:
	orig_stdout = sys.stdout
	orig_stdin = sys.stdin
	inputfile = open('W:/Competitive Programming/input.txt', 'r')
	outputfile = open('W:/Competitive Programming/output.txt', 'w')
	sys.stdin = inputfile
	sys.stdout = outputfile
mod = 1000000007

def nospace(l):
	ans = ''.join((str(i) for i in l))
	return ans
t = 1
for tt in range(t):
	(y, b, r) = map(int, sys.stdin.readline().split(' '))
	a1 = min(y + 2, min(r, b + 1))
	print(a1 + a1 - 1 + a1 - 2)
if fileoperation:
	sys.stdout = orig_stdout
	sys.stdin = orig_stdin
	inputfile.close()
	outputfile.close()


A = list(map(int, input().split()))
y = A[0]
b = A[1]
r = A[2]
s = 1
t = 2
u = 3
while u < r and t < b and (s < y):
	s = s + 1
	t = t + 1
	u = u + 1
print(s + t + u)


import sys
ybr = list(map(int, sys.stdin.readline().strip().split()))
print(3 * min([ybr[0], ybr[1] - 1, ybr[2] - 2]) + 3)


(y, b, r) = [int(s) for s in input().split()]
if r == b - 1 and b == y - 1:
	print(y + b + r)
elif b < r - 1:
	r = b + 1
	if y < b - 1:
		b = y + 1
		r = b + 1
		print(y + b + r)
	else:
		y = b - 1
		print(y + b + r)
else:
	b = r - 1
	if y < b - 1:
		print(3 * y + 3)
	else:
		y = b - 1
		print(y + b + r)


def main():
	[y, b, r] = [int(_) for _ in input().split()]
	y = min(y, b - 1, r - 2)
	print(3 * (y + 1))
main()


def chrismas_tree():
	lights = input().split()
	lights = [int(i) for i in lights]
	min_index = 0
	minimum = lights[0]
	for i in range(1, len(lights)):
		if lights[i] < minimum:
			minimum = i
			min_index = i
	if min_index == 0:
		while True:
			if lights[1] > lights[0] and lights[2] > lights[0] + 1:
				print(lights[0] + (lights[0] + 1) + (lights[0] + 2))
				return
			else:
				lights[0] -= 1
	elif min_index == 1:
		while True:
			if lights[0] >= lights[1] - 1 and lights[2] > lights[1]:
				print(lights[1] - 1 + lights[1] + (lights[1] + 1))
				return
			else:
				lights[1] -= 1
	else:
		while True:
			if lights[2] - 2 <= lights[0] and lights[2] - 1 <= lights[1]:
				print(lights[2] + (lights[2] - 1) + (lights[2] - 2))
				return
			else:
				lights[2] -= 1
chrismas_tree()


import math, itertools, fractions, heapq, collections, bisect, sys, queue, copy
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
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 I():
	return int(sys.stdin.readline())

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

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

def S():
	return input()

def main():
	(a, b, c) = LI()
	ans = 0
	for i in range(1000):
		if a >= i and b >= i + 1 and (c >= i + 2):
			ans = i * 3 + 3
		else:
			return ans
print(main())


(y, b, r) = list(map(int, input().split()))
m = r
if m - 1 <= b and m - 2 <= y:
	print(m + m - 1 + m - 2)
elif m - 1 > b:
	m -= m - 1 - b
	if m - 1 <= b and m - 2 <= y:
		print(m + m - 1 + m - 2)
	elif m - 2 > y:
		m -= m - 2 - y
		if m - 1 <= b and m - 2 <= y:
			print(m + m - 1 + m - 2)
elif m - 2 > y:
	m -= m - 2 - y
	if m - 1 <= b and m - 2 <= y:
		print(m + m - 1 + m - 2)


(y, b, r) = map(int, input().split())
maxx = 0
cur = 0
for i in range(1, 101):
	if y >= i and b >= i + 1 and (r >= i + 2):
		cur = 3 * i + 3
		if cur > maxx:
			maxx = cur
print(maxx)


flag = 0
(y, b, r) = map(int, input().split())
for ir in range(r, 2, -1):
	for ib in range(b, 1, -1):
		for iy in range(y, 0, -1):
			if ir == ib + 1 and ib == iy + 1:
				print(ir + ib + iy)
				flag = 1
				break
		if flag == 1:
			break
	if flag == 1:
		break


(y, b, r) = map(int, input().split())
ans = 6
for i in range(2, y + 1):
	x = i + 1
	z = x + 1
	if x > b or z > r:
		break
	ans = max(ans, i + x + z)
print(ans)


(a, b, c) = map(int, input().split())
a = min(a, b - 1, c - 2)
b = min(b, a + 1, c - 1)
c = min(c, a + 2, b + 1)
print(a + b + c)


__author__ = 'Dilshod'
(y, b, r) = map(int, input().split())
for i in range(y, 0, -1):
	if i + 1 <= b and i + 2 <= r:
		print(i * 3 + 3)
		break


(y, b, r) = map(int, input().split())
if b > r or b == r:
	b = r - 1
if y > b or y == b:
	y = b - 1
if b > y + 1:
	b = y + 1
if r > b + 1:
	r = b + 1
total = y + b + r
print(total)


(yellow, blue, red) = map(int, input().split())
flag = True
while flag == True:
	if blue >= yellow + 1 and red >= yellow + 2:
		print(yellow + yellow + 1 + yellow + 2)
		break
	else:
		yellow = yellow - 1


def mi():
	return list(map(int, input().split()))
(y, b, r) = mi()
if b >= r:
	b = r - 1
else:
	r = b + 1
if y >= b:
	y = b - 1
else:
	b = y + 1
	r = b + 1
print(y + r + b)


s = input().split()
(y, b, r) = (int(s[0]), int(s[1]), int(s[2]))
x = min(y + 2, b + 1, r)
if x == r:
	print(r * 3 - 3)
elif x == b + 1:
	print(b * 3)
elif x == y + 2:
	print(y * 3 + 3)


(y, b, r) = list(map(int, input().strip().split()))
if min(y, b, r) == y:
	for j in range(y, 0, -1):
		if b >= j + 1 and r >= j + 2:
			print(j * 3 + 3)
			break
elif min(y, b, r) == b:
	for j in range(b, 0, -1):
		if y >= j - 1 and r >= j + 1:
			print(j * 3)
			break
elif min(y, b, r) == r:
	for j in range(r, 0, -1):
		if y >= j - 2 and b >= j - 1:
			print(j * 3 - 3)
			break


import time
start_time = time.time()
from sys import stdin, stdout
from bisect import bisect_left, bisect_right
from collections import defaultdict
import math
from fractions import Fraction as frac
from random import random
cin = stdin.readline

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

def var(type=int):
	return type(stdin.readline())

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

def readlist(type=int):
	return list(map(type, stdin.readline().split()))

def sorted_indexes(arr):
	return sorted(range(len(arr)), key=arr.__getitem__)

def printr(arr):
	[stdout.write(str(x) + ' ') for x in arr]
	cout('')

def find_lt(a, x):
	i = bisect_left(a, x)
	if i:
		return a[i - 1]
	raise ValueError

def find_gt(a, x):
	i = bisect_right(a, x)
	if i != len(a):
		return a[i]
	raise ValueError

def primes(n):
	pmx = []
	f = 1
	for k in range(2, n):
		f = f * (k - 1)
		if (f + 1) % k == 0:
			pmx.append(k)
	return pmx

def binary_search(arr, x):
	i = bisect_left(arr, x)
	if i == len(arr) or arr[i] != x:
		return -1
	return i
MOD1 = 1000000007
MOD2 = 998244353
(y, b, r) = readline(int)
ans = 0
for k in range(y + 1):
	if k > y or k + 1 > b or k + 2 > r:
		break
	else:
		ans = k
print(3 * ans + 3)


import sys
inf = float('inf')
mod = 1000000007

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

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

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

def int1():
	return int(input())
import string
import math
from itertools import combinations

def main():
	a = get_array()
	b = a[0]
	y = a[1]
	r = a[2]
	z = 0
	while z == 0:
		if b + 1 <= y and b + 2 <= r:
			x = b + 1
			x1 = b + 2
			z = 1
			break
		else:
			b = b - 1
	print(b + x + x1)
main()


(o1, o2, o3) = map(int, input().split())
(a, b, c) = (1, 2, 3)
while a <= o1 and b <= o2 and (c <= o3):
	(a, b, c) = (a + 1, b + 1, c + 1)
print(a + b + c - 3)


(y, b, r) = input().split()
y = int(y)
b = int(b)
r = int(r)
ans = min(y, b - 1, r - 2)
print(ans + ans + 1 + ans + 2)


(y, b, r) = list(map(int, input().split()))
s = 0
for i in range(1, 100):
	if i <= y and i + 1 <= b and (i + 2 <= r):
		s = 3 * i + 3
print(s)


a = list(map(int, input().split()))
b = a[0]
c = a[1]
d = a[2]
sjmallest = 0
if a[0] > a[1]:
	if a[1] > a[2]:
		smallest = a[2]
	else:
		smallest = a[1]
elif a[0] > a[2]:
	smallest = a[2]
else:
	smallest = a[0]
if b == smallest:
	for h in range(b):
		if c >= b + 1 and d >= b + 2:
			a[1] = b + 1
			a[2] = b + 2
			print(a[0] + a[1] + a[2])
			break
		b = b - 1
		a[0] = a[0] - 1
elif c == smallest:
	for h in range(c):
		if b >= c - 1 and d >= c + 1:
			a[0] = c - 1
			a[2] = c + 1
			print(a[0] + a[1] + a[2])
			break
		c = c - 1
		a[1] = a[1] - 1
else:
	for h in range(d):
		if b >= d - 2 and c >= d - 1:
			a[0] = d - 2
			a[1] = d - 1
			print(a[0] + a[1] + a[2])
			break
		d = d - 1
		a[2] = a[2] - 1


x = input().split()
for i in range(3):
	x[i] = int(x[i])
	x[i] += 2 - i
print(min(x) * 3 - 3)


(a, b, c) = list(map(int, input().split()))
print(min(3 * a + 3, 3 * b, 3 * c - 3))


(y, b, r) = map(int, input().split())
while r - 1 != b:
	if b > r - 1:
		b -= 1
	else:
		r -= 1
while b - 1 != y:
	if y > b - 1:
		y -= 1
	else:
		b -= 1
		r -= 1
print(y + b + r)


(y, b, r) = map(int, input().split())
s = 0
i = 1
while i <= y and i + 1 <= b and (i + 2 <= r):
	s = 3 * i + 3
	i += 1
print(s)


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

def main():
	(y, b, r) = input_ints()
	print(3 * min([y + 1, b, r - 1]))
main()


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():
	a = LI()
	a[0] += 1
	a[2] -= 1
	t = min(a)
	return t * 3
print(main())


n = list(map(int, input().split()))
y = n[0]
b = n[1]
r = n[2]
for i in range(y, 0, -1):
	if i + 1 <= b and i + 2 <= r:
		print(i + (i + 1) + (i + 2))
		break
	else:
		continue


(y, b, r) = map(int, input().split())
Y = 0
B = Y + 1
R = B + 1
i = 0
while Y != y and B != b and (R != r):
	Y = Y + 1
	B = B + 1
	R = R + 1
s = Y + B + R
print(s)


(y, b, r) = [int(x) for x in input().split()]
start = y
while start >= 1:
	if start + 1 <= b and start + 2 <= r:
		break
	start -= 1
print(start + start + 1 + start + 2)


S = input().split(' ')
y = 0
b = 1
r = 2
for i in range(3):
	S[i] = int(S[i])
while y < S[0] and b < S[1] and (r < S[2]):
	y += 1
	b += 1
	r += 1
print(y + b + r)


(y, b, r) = map(int, input().split())

def func(y, b, r):
	while y > 0:
		if b >= y + 1 and r >= y + 2:
			return 3 * (y + 1)
		else:
			y -= 1
print(func(y, b, r))


(y, b, r) = map(int, input().split())
if min(y, b, r) == r:
	x = 3 * (r - 1)
elif min(y, b, r) == b:
	x = 3 * b
elif min(y, b, r) == y:
	if y + 1 == r:
		y -= 1
		x = 3 * (y + 1)
	else:
		x = 3 * (y + 1)
print(x)


def r(a, b):
	ans = a // b
	if a % b != 0:
		ans += 1
	return ans
(y, b, r) = map(int, input().split())
ans = min(y, b - 1, r - 2)
print(3 * ans + 3)


(y, b, r) = map(int, input().split())
m = min(y, b, r)
if m == y:
	if r - y >= 2 and b - y >= 1:
		print(y + (y + 1) + (y + 2))
	elif r - y >= 1:
		print(y - 1 + y + (y + 1))
	else:
		print(y - 2 + (y - 1) + y)
elif m == b:
	if r - b == 0:
		print(b - 1 + (b - 2) + b)
	else:
		print(b + (b + 1) + (b - 1))
else:
	print(r + (r - 1) + (r - 2))


(a, b, c) = [int(x) for x in input().split()]
aa = a * 3 + 3
bb = b * 3
cc = c * 3 - 3
print(min(aa, min(bb, cc)))


l = list(map(int, input().split()))

def count_ornament(y, b, r):
	if y >= r - 2 and b >= r - 1:
		return 3 * (r - 1)
	else:
		return count_ornament(y, b, r - 1)
print(count_ornament(l[0], l[1], l[2]))


a = [int(x) for x in input().split()]
f = a[0] + 1 + a[0] + 2 + a[0]
g = a[1] - 1 + a[1] + 1 + a[1]
h = a[2] - 1 + a[2] - 2 + a[2]
v = min(f, g, h)
print(v)


a = input().split()
for i in range(3):
	a[i] = int(a[i])
a[0] = a[0] + 1
a[2] = a[2] - 1
print(3 * min(a))


(a, b, c) = map(int, input().split())
ans = [min(a, b - 1, c - 2), min(a + 1, b, c - 1), min(a + 2, b + 1, c)]
print(ans[0] + ans[1] + ans[2])


(y, b, r) = map(int, input().split())
if min(y, b, r) == r:
	print(0 if 3 * r - 3 < 0 else 3 * r - 3)
elif min(y, b, r) == b:
	print(0 if 3 * b < 0 else 3 * b)
else:
	if r - y < 2 or b - y < 1:
		y -= 1
	print(0 if 3 * y + 3 < 0 else 3 * y + 3)


input_string = input()
(y, b, r) = input_string.split()
y = int(y)
b = int(b)
r = int(r)
list_a = [y, b - 1, r - 2]

def n_min():
	for i in range(len(list_a)):
		a = list_a[i]
		b = min(list_a)
		if list_a[i] == min(list_a):
			return i

def fin(n):
	if n == 0:
		a = y + (y + 1) + (y + 2)
		print(a)
	elif n == 1:
		a = b - 1 + b + (b + 1)
		print(a)
	elif n == 2:
		a = r - 2 + (r - 1) + r
		print(a)
fin(n_min())


(y, b, r) = map(int, input().split())
mini = min(y, b, r)
ans = (0, 0, 0)
if y == mini:
	while y + 1 > b or y + 2 > r:
		y -= 1
	ans = (y, y + 1, y + 2)
elif b == mini:
	while b + 1 > r:
		b -= 1
	ans = (b - 1, b, b + 1)
else:
	ans = (r - 2, r - 1, r)
print(sum(ans))


(y, b, r) = list(map(int, input().split()))
mmin = min(y, b)
mmin = min(mmin, r)
if y == b and y == r:
	ans = 3 * y - 3
elif mmin == r:
	ans = r + r - 1 + r - 2
elif mmin == b:
	if r == mmin:
		ans = r + r - 1 + r - 1
	else:
		ans = 3 * b
elif r >= mmin + 2:
	ans = 3 * mmin + 3
else:
	ans = 3 * mmin
print(ans)


(x, y, z) = [int(_) for _ in input().split()]
while x + 1 != y or y + 1 != z:
	if x < y - 1:
		y = x + 1
	elif x > y - 1:
		x = y - 1
	if y < z - 1:
		z = y + 1
	elif y > z - 1:
		y = z - 1
print(x + y + z)


print(min([int(x) - i for (i, x) in enumerate(input().split())]) * 3 + 3)


(y, b, r) = map(int, input().split())
y = y + 2
b = b + 1
r = r + 0
min = min(y, b, r)
sum = min * 3 - 3
print(sum)


x = []
x = list(map(int, input().split(' ')))
y = 1
b = 2
r = 3
while y <= x[0] and b <= x[1] and (r <= x[2]):
	y = y + 1
	b = b + 1
	r = r + 1
sum = y + b + r - 3
print(sum)


(n, m, k) = map(int, input().split())
print(min(n, m - 1, k - 2) * 3 + 3)


(y, b, r) = map(int, input().split())
m = 1
n = 2
o = 3
mix = 6
while m < y and n < b and (o < r):
	m += 1
	n += 1
	o += 1
	mix = m + n + o
print(mix)


(a, b, c) = map(int, input().split())
m = 1
for i in range(1, 103):
	if i <= a and i + 1 <= b and (i + 2 <= c):
		m = i
	else:
		break
print(3 * m + 3)


word = input()
x = word.split()
c = int(x[0])
b = int(x[1])
a = int(x[2])
if min(a, b, c) == a:
	print(3 * (a - 1))
elif min(a, b, c) == b:
	print(3 * b)
elif a - c == 1:
	print(3 * c)
else:
	print(3 * (c + 1))


ybr = list(map(int, input().rstrip().split()))
y = ybr[0]
b = ybr[1]
r = ybr[2]
if b >= y + 1 and r >= y + 2:
	result = y + (y + 1) + (y + 2)
if r >= b + 1 and y >= b - 1:
	result = b - 1 + b + (b + 1)
if y >= r - 2 and b >= r - 1:
	result = r - 2 + (r - 1) + r
print(result)


(a, b, c) = map(int, input().split())
(d1, d2, d3) = (0, 0, 0)
if a + 1 <= b and a + 2 <= c:
	d1 = 3 * a + 3
if b + 1 <= c and b - 1 <= a:
	d2 = b * 3
if c - 1 <= b and c - 2 <= a:
	d3 = c * 3 - 3
print(max(d1, d2, d3))


(y, b, r) = map(int, input().split())
for i in range(r, -1, -1):
	for j in range(b, -1, -1):
		for k in range(y, -1, -1):
			if i - j == 1 and j - k == 1:
				print(i + j + k)
				exit()


(a, b, c) = map(int, input().split())
summ = 0
for k1 in range(a + 1):
	for k2 in range(b + 1):
		for k3 in range(c + 1):
			if k1 == k2 - 1 and k2 == k3 - 1:
				if k1 + k2 + k3 > summ:
					summ = k1 + k2 + k3
print(summ)


x = list(map(int, input().split()))
a = 1
b = 2
c = 3
while x[0] > a and x[1] > b and (x[2] > c):
	a = a + 1
	b = b + 1
	c = c + 1
print(a + b + c)


from math import inf

def main():
	arr = input().split()
	maxi = min((int(arr[0]), int(arr[1]) - 1, int(arr[2]) - 2))
	print(maxi * 3 + 3)
main()


(y, b, r) = map(int, input().split())
Max = 0
for i in range(1, 100):
	if i <= y and i <= b - 1 and (i <= r - 2):
		Max = 3 * (i + 1)
	else:
		break
print(Max)


s = list(map(int, input().split()))
t = min(s)
if s[2] - s[0] >= 2 and s[1] - s[0] >= 1:
	print(3 * s[0] + 3)
elif s[2] <= s[0] + 2 and s[2] <= s[1] + 1:
	print(3 * s[2] - 3)
elif s[1] <= s[0] + 1 and s[1] <= s[2] + 1:
	print(3 * s[1])


s = input()
s = s.split()
if int(s[-1]) <= int(s[-2]):
	s[-2] = int(s[-1]) - 1
elif int(s[-2]) == int(s[-1]) - 1:
	pass
else:
	s[-1] = int(s[-2]) + 1
if int(s[-2]) <= int(s[-3]):
	s[-3] = int(s[-2]) - 1
elif int(s[-3]) == int(s[-2]) - 1:
	pass
else:
	s[-2] = int(s[-3]) + 1
	s[-1] = int(s[-2]) + 1
s = [int(x) for x in s]
print(sum(s))


(y, b, r) = map(int, input().split())
minn = min(y, b, r)
if r == minn:
	print(r + r - 1 + r - 2)
elif b == minn:
	print(b + 1 + b + b - 1)
elif r >= y + 2:
	print(y + y + 1 + y + 2)
else:
	print(y - 1 + y + y + 1)


(y, b, r) = input().split()
(y, b, r) = (int(y), int(b), int(r))
(l, m, n) = (0, 1, 2)
while l != y and m != b and (n != r):
	l += 1
	m += 1
	n += 1
print(l + m + n)


(e, b, r) = map(int, input().split())
a = min(e, min(b - 1, r - 2))
if a == r - 2:
	print(r - 2 + r - 1 + r)
elif a == b - 1:
	print(b + b + b)
else:
	print(e + e + e + 3)


import sys

def inpt():
	return sys.stdin.readline().strip()
x = [int(i) for i in inpt().split()]
m = min(x)
if m == x[2]:
	print(3 * m - 3)
elif m == x[1]:
	if m + 1 > x[2]:
		m -= 1
	print(3 * m)
elif m == x[0]:
	if m + 1 > x[1]:
		m -= 1
	if m + 2 > x[2]:
		m -= 1
	print(3 * m + 3)


(max_y, max_b, max_r) = map(int, input().split(' '))
y = min(max_y, max_b - 1, max_r - 2)
b = y + 1
r = y + 2
print(y + b + r)


from sys import stdin

def main():
	(Y, B, R) = map(int, input().split())
	for y in range(Y, 0, -1):
		if y < B and y + 1 < R:
			print(y * 3 + 3)
			break
input = lambda : stdin.readline()
main()


(y, b, r) = map(int, input().split())
i = 1
j = 2
k = 3
m = max(y, b, r)
ans = 0
for z in range(m):
	if i <= y and j <= b and (k <= r):
		if k == j + 1 and j == i + 1:
			ans = max(ans, i + j + k)
	i += 1
	j += 1
	k += 1
print(ans)


import sys
(y, b, r) = map(int, input().split())
ans = 0
for i in range(1, y + 1):
	if b > i and r > i + 1:
		ans = max(ans, 3 * i + 3)
print(ans)


import sys

def main():
	(y, b, r) = [int(x) for x in sys.stdin.readline().split()]
	result = 0
	for i in range(1, y + 1):
		if y >= i and b >= i + 1 and (r >= i + 2):
			result = max(result, i * 3 + 3)
	print(result)
main()


def bool(index, y, b, r):
	if index == 1:
		return 3 * y + 3
	elif index == 2:
		return 3 * b
	else:
		return 3 * r - 3
x = input()
x = x.split(' ')
(y, b, r) = (int(x[0]), int(x[1]), int(x[2]))
min_bool = min(y, b, r)
if b >= y + 1 and r >= y + 2:
	index = 1
elif b < y + 1 and r >= b + 1:
	index = 2
else:
	index = 3
out = bool(index, y, b, r)
print(out)


(a, b, c) = [int(i) for i in input().split()]
i = 0
while True:
	y = c - i - 2
	if y + 1 <= b and y <= a:
		break
	i += 1
print(3 * y + 3)


[a, b, c] = [int(x) for x in input().split()]
ornaments = min(a - 1, b - 2, c - 3) * 3 + 6
print(ornaments)


(y, b, r) = map(int, input().split())
p = min(y, b, r)
z = max(y, b, r)
if y == b == r:
	print(3 * r - 3)
elif p == r:
	print(3 * r - 3)
elif p == b:
	print(3 * b)
elif z == b and y + 2 <= r:
	print(3 * y + 3)
elif z == r and y + 2 <= r:
	print(3 * y + 3)
else:
	print(3 * (y - 1) + 3)


c = input()
f = list(c).index(' ')
y = int(c[:f])
b = int(c[f:list(c).index(' ', f + 1)])
r = int(c[list(c).index(' ', f + 1):])
for d in reversed(range(1, y + 1)):
	if d + 1 <= b and d + 2 <= r:
		l = 3 * d + 3
		print(l)
		exit(0)


num = input()
a = []

def get_the_data(count, num, arr):
	for i in range(0, len(num)):
		if num[i] == ' ':
			arr.append(int(num[count:i]))
			count = i + 1
		elif i == len(num) - 1:
			arr.append(int(num[count:len(num)]))
	return arr
arr = get_the_data(0, num, a)
result = False
while result is False:
	if arr[0] + 1 <= arr[1] and arr[0] + 2 <= arr[2]:
		print(arr[0] + arr[0] + arr[0] + 3)
		break
	else:
		arr[0] -= 1


(y, b, r) = map(int, input().rstrip().split())
modified = [y + 2, b + 1, r]
modified.sort()
total = 3 * modified[0] - 3
print(total)


l = [int(e) for e in input().split()]
lst = []
for e in range(1, l[0] + 1):
	if e + 1 <= l[1] and e + 2 <= l[2]:
		lst.append((e, e + 1, e + 2))
print(sum(lst[-1]))


R = lambda : map(int, input().split())
(y, b, r) = R()
print(3 * min(y + 1, b, r - 1))


def new_years(y, b, r):
	if r < b + 1:
		b = r - 1
	if b < y + 1:
		y = b - 1
	return 3 * y + 3
x = list(map(int, input().rstrip().split()))
print(new_years(x[0], x[1], x[2]))


entrada = input()
entrada = [int(x) for x in entrada.split()]
(y, b, r) = (entrada[0], entrada[1], entrada[2])
y = y + 2
b = b + 1
delta = min(y, b, r)
print(3 * delta - 3)


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))
(a, b, c) = get_int_list()
if b >= c:
	b = c - 1
else:
	c = b + 1
if a >= b:
	a = b - 1
else:
	b = a + 1
	if c > b + 1:
		c = b + 1
print(a + b + c)


(y, b, r) = list(map(int, input().split()))
s = 0
while s != 1:
	if r - 1 <= b and r - 2 <= y:
		s = 1
	else:
		r -= 1
print(r - 2 + r - 1 + r)


nn = input()
nn = nn.split()
y = int(nn[0])
b = int(nn[1])
r = int(nn[2])
m = None
for i in range(1, y + 1):
	for j in range(1, b + 1):
		for k in range(1, r + 1):
			if k == j + 1 and j == i + 1:
				if m == None or m < i + j + k:
					m = i + j + k
print(m)


(a, b, c) = map(int, input().split())
r = 0
g = 0
x = 0
m = 0
for i in range(1, a + 1):
	if i <= a and i + 1 <= b and (i + 2 <= c):
		r = i
		g = i + 1
		x = i + 2
		if r + g + x > m:
			m = r + g + x
print(r + g + x)


read = lambda : map(int, input().split())
(x, y, z) = read()
m = min(x, y - 1, z - 2)
print(3 * m + 3)


(y, b, r) = list(map(int, input().split()))
if b >= r:
	b = r - 1
if y >= b:
	y = b - 1
while True:
	while r != b + 1:
		r -= 1
	while b != y + 1:
		b -= 1
	if r == b + 1 and b == y + 1:
		break
print(r + b + y)


(y, b, r) = [int(i) for i in input().split()]
if b + 1 > r:
	b = r - 1
elif b + 1 < r:
	r = b + 1
if y + 1 > b:
	y = b - 1
elif y + 1 < b:
	b = y + 1
if r > b + 1:
	r = b + 1
elif r < b + 1:
	b = r - 1
print(y + b + r)


(y, b, r) = map(int, input().split(' '))
(Y, B, R) = (1, 2, 3)
while Y < y and B < b and (R < r):
	Y += 1
	B += 1
	R += 1
print(Y + B + R)


(y, b, r) = [int(i) for i in input().split()]
minimum = min(y, b, r)
ay = 0
ab = 0
ar = 0
if minimum == y:
	ay = y
elif minimum == b:
	ab = b
else:
	ar = r
if ay:
	while 1:
		if b >= ay + 1 and r >= ay + 2:
			print(ay + ay + 1 + ay + 2)
			break
		else:
			ay -= 1
elif ab:
	while 1:
		if y >= ab - 1 and r >= ab + 1:
			print(ab - 1 + ab + ab + 1)
			break
		else:
			ab -= 1
else:
	while 1:
		if y >= ar - 2 and b >= ar - 1:
			print(ar + ar - 1 + ar - 2)
			break
		else:
			ar -= 1


def main():
	(a, b, c) = map(int, input().split())
	ans = 0
	if b >= a + 1 and c >= a + 2:
		ans = max(ans, a * 3 + 3)
	if a >= b - 1 and c >= b + 1:
		ans = max(ans, b * 3)
	if a >= c - 2 and b >= c - 1:
		ans = max(ans, c * 3 - 3)
	print(ans)
main()


(y, b, r) = list(map(int, input().strip().split()))
mini = min(y, b, r)
if mini == r:
	print(3 * r - 3)
elif mini == b:
	print(3 * b)
elif r - y > 1:
	print(3 * y + 3)
else:
	print(3 * y)


__author__ = 'Sudip'
a = list(map(int, input().split()))
b = [0] * 3
b[0] = a[0]
b[1] = a[1] - 1
b[2] = a[2] - 2
p = b.index(min(b))
print(a[p] * 3 + 3 - 3 * p)


(y, b, r) = map(int, input().split())
for i in range(r, 2, -1):
	r1 = i
	if i - 1 <= b:
		b1 = i - 1
	else:
		continue
	if i - 2 <= y:
		y1 = i - 2
	else:
		continue
	print(r1 + b1 + y1)
	break


(m, n, k) = [int(x) for x in input().split()]
tot = m
while 1:
	if tot + 1 > n or tot + 2 > k:
		tot -= 1
	else:
		print(tot * 3 + 3)
		break


(y, b, r) = [int(s) for s in input().split()]
if b >= r:
	b = r - 1
if y >= b:
	y = b - 1
b = y + 1
r = b + 1
print(sum((y, b, r)))


a = list(map(int, input().split()))
b = a[1] - 1
c = a[2] - 2
t = [a[0], b, c]
if a[0] == min(t):
	print(3 * a[0] + 3)
elif b == min(t):
	print(3 * a[1])
else:
	print(3 * a[2] - 3)


(y, b, r) = list(map(int, input().split()))
(x, y1, z) = (0, 0, 0)
for i in range(2, b + 1):
	if i - 1 <= y and i + 1 <= r:
		x = i - 1
		y1 = i
		z = i + 1
print(x + y1 + z)


(yel, blue, red) = map(int, input().split())
arr = []
f = 0
for i in range(red, 3, -1):
	if i - 2 <= yel and i - 1 <= blue:
		f = 1
		print(3 * i - 3)
		break
if f == 0:
	print(6)


(x, y, z) = map(int, input().split())
d = min(x + 1, z - 1)
s = min(y, d)
print(s * 3)


input_list = input().split()
y = eval(input_list[0])
b = eval(input_list[1])
r = eval(input_list[2])
number = min([y, b - 1, r - 2])
print(number * 3 + 3)


(a, b, c) = input().split()
a = int(a)
b = int(b)
c = int(c)
if a == b and b == c and (a == c):
	print(a + a - 1 + a - 2)
elif b == min(a, b, c) and b != c:
	n = b
	y = n - 1
	b = n
	r = n + 1
	print(y + b + r)
elif b == min(a, b, c) and b == c:
	n = c
	y = n - 2
	b = n - 1
	r = n
	print(y + b + r)
elif a == min(a, b, c) and a + 2 <= c and (a + 1 <= b):
	n = a
	y = n
	b = n + 1
	r = n + 2
	print(y + b + r)
elif a == min(a, b, c) and a + 2 > c and (a + 1 <= b):
	y = c
	b = c - 1
	r = c - 2
	print(y + b + r)
elif c == min(a, b, c):
	y = c - 2
	b = c - 1
	r = c
	print(y + b + r)


(y, b, r) = map(int, input().split(' '))
if r > b + 1:
	r = b + 1
else:
	b = r - 1
if y >= r or y >= b:
	y = b - 1
else:
	b = y + 1
	r = b + 1
print(b + r + y)


(a, b, c) = map(int, input().split())
f = min(c, b + 1)
q = f - 1
d = q - 1
if a < d:
	if b > a and c > a + 1:
		print(a + a + 1 + a + 2)
	else:
		print(0)
else:
	print(max(0, q + f + d))


arr = list(map(int, input().split()))
i = 2
j = 3
k = 4
ans = 6
flag = 0
while flag == 0:
	if i <= arr[0] and j <= arr[1] and (k <= arr[2]):
		ans += 3
		i += 1
		j += 1
		k += 1
	else:
		flag = 1
print(ans)


(y, b, r) = list(map(int, input().split()))
for i in range(1, r + 1):
	(ys, bs, rs) = (i, i + 1, i + 2)
	if ys > y or bs > b or rs > r:
		break
	sol = ys + bs + rs
print(sol)


(x, y, z) = [int(i) for i in input().split()]
if min(x, y, z) > z - 2:
	print((z - 1) * 3)
elif min(x, y, z) > y - 1:
	print(y * 3)
else:
	print((x + 1) * 3)