s=eval(input())

ans=10*100

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())



ans = []



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

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



print((min(ans)))

s = eval(input())
ans = 10 * 100
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())
ans = []
for i in range(len(S) - 2):
    ans.append(abs(int(S[i : i + 3]) - 753))
print((min(ans)))

-s = eval(input()) -ans = 10 * 100 -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()) +ans = [] +for i in range(len(S) - 2): +    ans.append(abs(int(S[i : i + 3]) - 753)) +print((min(ans)))