S = eval(input())

ans = 753

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

    if abs(753 - int(S[i: i + 3])) < ans:

        ans = abs(753 - int(S[i: i + 3]))

print(ans)
S = eval(input())

res = 753

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

    res = min(res, abs(int(S[i:i+3]) - 753))



print(res)
S = eval(input())
ans = 753
for i in range(len(S) - 2):
    if abs(753 - int(S[i : i + 3])) < ans:
        ans = abs(753 - int(S[i : i + 3]))
print(ans)

S = eval(input())
res = 753
for i in range(len(S) - 2):
    res = min(res, abs(int(S[i : i + 3]) - 753))
print(res)

-ans = 753 +res = 753 -    if abs(753 - int(S[i : i + 3])) < ans: -        ans = abs(753 - int(S[i : i + 3])) -print(ans) +    res = min(res, abs(int(S[i : i + 3]) - 753)) +print(res)