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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include <bits/stdc++.h>
using namespace std;
#define rep(a, b) for (int a = 0; a < (b); a++)
#define rep1(a, b) for (int a = 1; a <= (b); a++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int MOD = 1e9 + 7;

const int LIM = 1e6 + 7;
string a, b, c;

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    
    cin >> a >> b >> c;

    int dp0 = 0;
    int dp1 = 0;
    int dp0x = 0;
    int dp1x = 0;
    ll ans = 0;
    rep(i, a.size()) {
        int d1 = a[i]-'0';
        int d2 = b[i]-'0';
        int d3 = c[i]-'0';
        if (d1+d2 == d3) {
            dp0x = 1+dp0;
            dp1x = 0;
        } else if (d1+d2 == 10+d3) {
            dp0x = dp1;
            dp1x = 0;
        } else if (d1+d2+1 == d3) {
            dp0x = 0;
            dp1x = 1+dp0;
        } else if (d1+d2+1 == 10+d3) {
            dp0x = 0;
            dp1x = dp1;
        } else {
            dp0x = 0;
            dp1x = 0;
        }
        dp0 = dp0x;
        dp1 = dp1x;
        ans += dp0;
    }
    cout << ans << "\n";

    return 0;
}