n = list(eval(input()))

m = []

ans = []

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

    s = n[i] + n[i+1] + n[i+2]

    m.append(int(s))

    

for j in m:

    ans.append(abs(753 - j))

    

print((min(ans)))
n = eval(input())

m = [int(n[i:i+3]) for i in range(len(n)-2)]

ans = [abs(753 - j) for j in m]

print((min(ans)))
n = list(eval(input()))
m = []
ans = []
for i in range(len(n) - 2):
    s = n[i] + n[i + 1] + n[i + 2]
    m.append(int(s))
for j in m:
    ans.append(abs(753 - j))
print((min(ans)))

n = eval(input())
m = [int(n[i : i + 3]) for i in range(len(n) - 2)]
ans = [abs(753 - j) for j in m]
print((min(ans)))

-n = list(eval(input())) -m = [] -ans = [] -for i in range(len(n) - 2): -    s = n[i] + n[i + 1] + n[i + 2] -    m.append(int(s)) -for j in m: -    ans.append(abs(753 - j)) +n = eval(input()) +m = [int(n[i : i + 3]) for i in range(len(n) - 2)] +ans = [abs(753 - j) for j in m]