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
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

bool jest(string a,string b,string c, int po, int ko){
    string poma= a.substr(po,ko-po+1);
    string pomb= b.substr(po,ko-po+1);
    string pomc= c.substr(po,ko-po+1);
    //cout<<stoi(poma)<<" "<<stoi(pomb)<<" "<<stoi(pomc)<<" "<<endl;
    if(stoi(poma)+stoi(pomb)==stoi(pomc))return true;
    return false;
}

int main(){
    string a,b,c;
    cin>>a;
    cin>>b;
    cin>>c;
    int odp;
    int n=a.size();
    int po=n-1,ko=n-1;
    while(po!=-1){
        if(jest(a,b,c,po,ko)){
            odp++;
            //cout<<po+1<<" "<<ko+1<<endl;
            if(jest(a,b,c,po,po) && po!=ko){
                    //cout<<po+1<<" "<<po+1<<endl;
                    ++odp;
            }
            --po;
        }
        else{
            if(po==ko)--po;
            else ko=po;
        }
    }
    cout<<odp;
    return 0;

}