#include <iostream>
using namespace std;
int main()
{
    char n1, n2, c1, c2, k, m;
    cin>>n1>>c1>>n2>>c2>>k;
    if(c1=='A')
    {
        while(k>0)
        {
            if(n1>0)
            {
                n1--;
            }
            break;
        }
        cout>>n1;
    }
    return 0;
}
