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
52
53
54
55
56
57
58
59
60
61
62
63
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define all(a) a.begin(),a.end()
#define v vector
#define pb push_back

int rozw(char a, char b, char c){
    int x, y, z;
    x=int(a)-int('0');
    y=int(b)-int('0');
    z=int(c)-int('0');
    if(x+y==z) return 1;
    if((x+y)-10==z) return 2;
    if(x+y+1==z) return 3;
    if((x+y)-10+1==z) return 4;
    return 0;
}

int main(){ios_base::sync_with_stdio(0);cin.tie(0);
    string a,b,c;
    cin >> a >> b >> c;
    int n=a.size(), k=0, pom=0, dod=0;
    LL wyn=0;
    for(int i=0;i<n;i++){
        int x=rozw(a[i],b[i],c[i]);
        dod=0;
        // a+b=c
        if(x==1){
            if(pom) k=1;
            else k++;
            dod=1;
            pom=0;
        }
        // (a+b)%10=c
        if(x==2){
            if(pom==0) k=0;
            else{
                k++;
                pom=0;
                dod=1;
            }
        }
        // a+b+1=c
        if(x==3){
            if(pom==0) pom=1;
            else k=0;
        }
        // (a+b)%10+1=c
        if(x==4){
            if(pom==0) k=0;
        }
        if(x==0){
            pom=0;
            k=0;
        }
        if(dod) wyn+=k;
        //cout << k << ' '  << pom << ' ' << x << ' ' << dod <<  '\n';
    }
    cout << wyn;
    
    return 0;
}