#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int,int> P;
const int N=1e4+9;
const int M=2e5+9;
#define gt getchar();
#define line '\n'
#define is isdigit
int read(){int x=0,op=1;char c=gt;while(!is(c)){if(c=='-')op=-1;c=gt;}while(is(c))x=x*10+c-48,c=gt;return x*op;}
int main()
{
string A,B;
cin>>A>>B;
int L=A.length(),R=B.length();
if(L!=R)cout<<1<<line;
else{
if(A==B)cout<<2<<line;
else{
int mark=3;
for(int i=0;i<L;++i)if(A[i]!=B[i]&&abs(A[i]-B[i])!=32){
mark=4;
break;
}
cout<<mark<<line;
}
}
return 0;
}