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
64
65
#include <bits/stdc++.h>
#define int ll
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define rng(i,c,n) for(int i=c;i<n;i++)
#define fi first
#define se second
#define vec vector
#define pb push_back
#define sz(a) (int)a.size()
#define all(a) a.begin(),a.end()
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
void print(){cout<<'\n';}
template<class h,class...t>
void print(const h&v,const t&...u){cout<<v<<' ',print(u...);}

void slv(){
	string a,b,c;
	cin>>a>>b>>c;

	const int n=sz(a);

	vi dp(2);
	int ans=0;
	per(i,n){
		vi ndp(2);
		rep(carry,2){
			int x=a[i]-'0';
			int y=b[i]-'0';
			int z=c[i]-'0';
			int rz=x+y+carry;
			int ncarry=rz/10;
			rz%=10;
			if(rz==z and ncarry==0){
				ans+=dp[carry];
				if(carry==0){
					ans++;
				}
			}
			if(rz==z){
				ndp[ncarry]+=dp[carry];
				if(carry==0){
					ndp[ncarry]++;
				}
			}
		}
		dp.swap(ndp);
	}
	cout<<ans<<"\n";
}

signed main(){
	ios::sync_with_stdio(0),cin.tie(0);

	int t;
	t=1;
	// cin>>t;

	rep(cs,t){
		slv();
	}
}