s = eval(input())

min = 100000000

for i in range(len(s)-2):

  a = int(s[i:i+3])

  dis = ((753-a)**2)**0.5

  if dis <min:

    min =dis

print((int(min)))
s = list(eval(input()))

a =''

l =[]

for i in range(2,len(s)):

  a = s[i-2] + s[i-1] +s[i]

  a_n = int(''.join(a))

  b =abs(a_n-753)

  l.append(b)

print((min(l)))
s = eval(input())
min = 100000000
for i in range(len(s) - 2):
    a = int(s[i : i + 3])
    dis = ((753 - a) ** 2) ** 0.5
    if dis < min:
        min = dis
print((int(min)))

s = list(eval(input()))
a = ""
l = []
for i in range(2, len(s)):
    a = s[i - 2] + s[i - 1] + s[i]
    a_n = int("".join(a))
    b = abs(a_n - 753)
    l.append(b)
print((min(l)))

-s = eval(input()) -min = 100000000 -for i in range(len(s) - 2): -    a = int(s[i : i + 3]) -    dis = ((753 - a) ** 2) ** 0.5 -    if dis < min: -        min = dis -print((int(min))) +s = list(eval(input())) +a = "" +l = [] +for i in range(2, len(s)): +    a = s[i - 2] + s[i - 1] + s[i] +    a_n = int("".join(a)) +    b = abs(a_n - 753) +    l.append(b) +print((min(l)))