import numpy as np

import sys

s = eval(input())

ans = 753

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

    value = abs(753 - int(s[i:i+3]))

    ans = min(ans,value)

print(ans)

s=eval(input())

ans=1000

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)

import numpy as np
import sys

s = eval(input())
ans = 753
for i in range(len(s) - 2):
    value = abs(753 - int(s[i : i + 3]))
    ans = min(ans, value)
print(ans)

s = eval(input())
ans = 1000
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)

-import numpy as np -import sys - -ans = 753 +ans = 1000 -    value = abs(753 - int(s[i : i + 3])) -    ans = min(ans, value) +    if abs(753 - int(s[i : i + 3])) <= ans: +        ans = abs(753 - int(s[i : i + 3]))