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
#include <bits/stdc++.h>
#define pii pair<int, int>
#define For(i, l, r) for (int i=l;(l<=r?i<=r:i>=r);(l<=r?i++:i--))
//#define DEBUG
#ifdef DEBUG
auto operator<<(auto &o,auto p)->decltype(p.first,o){return o<<'('<<p.first<<", "<<p.second<<')';}
auto operator<<(auto &o,auto x)->decltype(x.end(),o){o<<'{';int i=2;for(auto &e:x)o<<(", ")+i<<e,i=0;return o<<'}';}
#define LOG(X...)cerr<<"["#X"]: ",[](auto...$){((cerr<<$<<"; "),...)<<endl;}(X);
#else
#define LOG(x...)(void)0
#endif
#define int long long
using namespace std;

const int inf=1e9+1;

void solve(){
    string a, b, c;
    cin >> a >> b >> c;
    int n = a.size(), res = 0;
    a = " " + a;
    b = " " + b;
    c = " " + c;
    for (int i = 1; i <= n; i++){
        a[i] -= '0';
        b[i] -= '0';
        c[i] -= '0';
    }
    vector<vector<int>> dp(2, vector<int>(n + 1));
    for (int i = 1; i <= n; i++){
        for (int j = 0; j < 2; j++){
            if ((a[i] + b[i] + j) % 10 == c[i]){
                if (a[i] + b[i] + j >= 10)
                    dp[j][i] = dp[1][i - 1];
                else
                    dp[j][i] = dp[0][i - 1] + 1;
            }
        }
        res += dp[0][i];
    }
    cout << res << '\n';
}

signed main(){
    cin.tie(0)->sync_with_stdio(0);
    int t=1;
    //cin >> t;
    while(t--)
        solve();
}