#!/usr/bin/env python3

import sys

def go(x, y):
    i = next((i for i in range(len(x)) if x[i] + y[i] >= 10), -1)
    if i < 0: return 0
    while i > 0 and x[i-1]+y[i-1] == 9: i -= 1
    return 10 ** len(x[i:]) - int(''.join(str(d) for d in x[i:]))

x = list(map(int, sys.stdin.readline()[:-1]))
y = list(map(int, sys.stdin.readline()[:-1]))
d = len(x)-len(y)
if d > 0: y = [0]*d + y
else: x = [0]*(-d) + x
print(min(go(x, y), go(y, x)))
