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
#include<set>
#include<map>
#include<queue>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
#define pr pair
#define f first
#define s second
#define ll long long
#define mp make_pair
#define pll pr<ll,ll>
#define pii pr<int,int>
#define piii pr<int,pii>
using namespace std;
string tp(int a,int b,int c)
{
	int g=(a+b)%10;
	string rt="00";
	if((g+1)%10==c) rt[1]='1',rt[0]+=(a+b+1-c)/10;
	else if(g!=c) return "23";
	else rt[0]+=(a+b-c)/10;
	return rt;
}
int main()
{
	ios_base::sync_with_stdio(0);
	int n;
	string a,b,c;
	cin>>a>>b>>c;
	n=a.size();
	int cz=0;
	char ls='0';
	ll ans=0;
	for(int i=0;i<n;i++)
	{
		string g=tp(a[i]-'0',b[i]-'0',c[i]-'0');
		if(g[0]!=ls) cz=0;
		if(g[0]=='0') cz++;
		ls=g[1];
		if(ls=='0') ans+=cz;
	}
	cout<<ans<<endl;
	return 0;
}