#include <iostream>
#include <algorithm>
using namespace std;
string s,t;
int answer = 0;
void getAnswer(string word) {
while(true) {
if(word.length()==s.length()) {
if(word==s) answer = 1;
break;
}
if(word[word.length()-1]=='B') {
word = word.substr(0,word.length()-1);
reverse(word.begin(), word.end());
} else {
word = word.substr(0,word.length()-1);
}
}
}
int main() {
cin>>s>>t;
getAnswer(t);
cout<<answer;
}