import itertools

import math

import fractions

import functools

import copy



n = eval(input())

minimum = 1000

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

    num = int(n[i:i+3])

    minimum = min(minimum,abs(num-753))

print(minimum)

def main():

    # n = int(input())

    # t, a = map(int, input().split())

    # h = list(map(int, input().split()))

    s = eval(input())

    mini = 10**10

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

        mini = min(mini, abs(int(s[i:i+3]) - 753))



    print(mini)





if __name__ == '__main__':

    main()

import itertools
import math
import fractions
import functools
import copy

n = eval(input())
minimum = 1000
for i in range(len(n) - 2):
    num = int(n[i : i + 3])
    minimum = min(minimum, abs(num - 753))
print(minimum)

def main():
    # n = int(input())
    # t, a = map(int, input().split())
    # h = list(map(int, input().split()))
    s = eval(input())
    mini = 10**10
    for i in range(len(s) - 2):
        mini = min(mini, abs(int(s[i : i + 3]) - 753))
    print(mini)


if __name__ == "__main__":
    main()

-import itertools -import math -import fractions -import functools -import copy +def main(): +    # n = int(input()) +    # t, a = map(int, input().split()) +    # h = list(map(int, input().split())) +    s = eval(input()) +    mini = 10**10 +    for i in range(len(s) - 2): +        mini = min(mini, abs(int(s[i : i + 3]) - 753)) +    print(mini) -n = eval(input()) -minimum = 1000 -for i in range(len(n) - 2): -    num = int(n[i : i + 3]) -    minimum = min(minimum, abs(num - 753)) -print(minimum) + +if __name__ == "__main__": +    main()