import numpy as np

S = eval(input())

l = []

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

    l.append(int(S[i:i+3]))



l = np.array(l)

l -= 753



for i in range(len(l)):

    if l[i] <0:

        l[i] = - l[i]



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

l = []

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

    tmp = int(S[i:i+3])

    l.append(abs(tmp-753))



print((min(l)))

import numpy as np

S = eval(input())
l = []
for i in range(len(S) - 2):
    l.append(int(S[i : i + 3]))
l = np.array(l)
l -= 753
for i in range(len(l)):
    if l[i] < 0:
        l[i] = -l[i]
print((min(l)))

S = eval(input())
l = []
for i in range(len(S) - 2):
    tmp = int(S[i : i + 3])
    l.append(abs(tmp - 753))
print((min(l)))

-import numpy as np - -    l.append(int(S[i : i + 3])) -l = np.array(l) -l -= 753 -for i in range(len(l)): -    if l[i] < 0: -        l[i] = -l[i] +    tmp = int(S[i : i + 3]) +    l.append(abs(tmp - 753))