@staticmethod
def b():
    (a, b) = map(int, sys.stdin.read().split())
    d = abs((a - b))
    print(min(d, (10 - d)))
@staticmethod
def b():
    (a, b) = map(int, sys.stdin.read().split())
    d = abs((a - b))
    print(min(d, (10 - d)))