1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
def main():
    number_a = input()
    number_b = input()
    number_c = input()

    a = [int(c) for c in number_a]
    b = [int(c) for c in number_b]
    c = [int(c) for c in number_c]

    # print(a, b, c)

    dp = [[0, 0]]
    total = 0

    for i in range(len(a)):
        dp.append([0, 0])
        if a[i] + b[i] == c[i]:
            dp[-1][0] += 1 + dp[-2][0]
        elif a[i] + b[i] == 10 + c[i]:
            dp[-1][0] += dp[-2][1]
        elif a[i] + b[i] + 1 == c[i]:
            dp[-1][1] += 1 + dp[-2][0]
        elif a[i] + b[i] + 1 == c[i] + 10:
            dp[-1][1] += dp[-2][1]
        total += dp[-1][0]
    # print(dp)
    print(total)


if __name__ == "__main__":
    main()