import math

S = eval(input())

thlist = [(753 - int(S[i:i+3]))**2 for i in range(len(S)-2)]

print((int(math.sqrt(min(thlist)))))
S = eval(input())

thlist = [abs(753 - int(S[i:i+3])) for i in range(len(S)-2)]

print((min(thlist)))
import math

S = eval(input())
thlist = [(753 - int(S[i : i + 3])) ** 2 for i in range(len(S) - 2)]
print((int(math.sqrt(min(thlist)))))

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

-import math - -thlist = [(753 - int(S[i : i + 3])) ** 2 for i in range(len(S) - 2)] -print((int(math.sqrt(min(thlist))))) +thlist = [abs(753 - int(S[i : i + 3])) for i in range(len(S) - 2)] +print((min(thlist)))