#include <iostream>
using namespace std;
int main ()
{
int x,y,a,b,c,d,i,z,n=0;
while (x!=0 && y!=0)
{
cin>>x>>y;
a=x; b=y;
i=0;z=1;
while (a!=0)
{
a=a/10; i++;
}
for (int j=1;j<=i;j=j*10)
z=j;
c=b*z+a;
i=0;z=1;
while (b!=0)
{
b=b/10; i++;
}
for (int j=1;j<=i;j=j*10)
z=j;
d=a*z+b;
if (c==d)
n++;
}
cout<<n;
return 0;
}