S = list(map(int, list(eval(input()))))

l = len(S)

list = []

for i in range(l-2):

    a = 100 * S[i]

    b = 10 * S[i+1]

    c = S[i+2]

    n = a + b + c

    list.append(abs(n-753))



print((min(list)))
S = list(eval(input()))

ans = float('inf')

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

    s = int("".join(S[i:i+3]))

    ans = min(ans, abs(753-s))

print(ans)
S = list(map(int, list(eval(input()))))
l = len(S)
list = []
for i in range(l - 2):
    a = 100 * S[i]
    b = 10 * S[i + 1]
    c = S[i + 2]
    n = a + b + c
    list.append(abs(n - 753))
print((min(list)))

S = list(eval(input()))
ans = float("inf")
for i in range(len(S) - 2):
    s = int("".join(S[i : i + 3]))
    ans = min(ans, abs(753 - s))
print(ans)

-S = list(map(int, list(eval(input())))) -l = len(S) -list = [] -for i in range(l - 2): -    a = 100 * S[i] -    b = 10 * S[i + 1] -    c = S[i + 2] -    n = a + b + c -    list.append(abs(n - 753)) -print((min(list))) +S = list(eval(input())) +ans = float("inf") +for i in range(len(S) - 2): +    s = int("".join(S[i : i + 3])) +    ans = min(ans, abs(753 - s)) +print(ans)