import numpy as np

S = input().strip()

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

print((min([abs(753 - int(S[i:i+3])) for i in range(len(S) - 2)]))) 
import numpy as np

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

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

-import numpy as np - -print((min([np.abs(753 - int(S[i : i + 3])) for i in range(len(S) - 2)]))) +print((min([abs(753 - int(S[i : i + 3])) for i in range(len(S) - 2)])))