#include<iostream>
using namespace std;
int main()
{
long long brlqvo,brdqsno,k;
char simbol1,simbol2;
cin>>brlqvo>>simbol1;
cout<<"\n";
cin>>brdqsno>>simbol2;
cout<<"\n";
cin>>k;
long long izh;
if(simbol1=='A')
{
izh=izh+brlqvo;
}
if(simbol1='B')
{
izh=izh+brdqsno;
}
cout<<izh;
return 0;
}