#include <iostream>
using namespace std;

int main () {

char n1, c1, n2, c2, k, A;
int n2vz, otg;
cin >> n1 >> c1;
cin >> n2 >> c2;
cin >> k ;



if (k>n1)
{
n2vz = k - n1;
}
if (c2 == A) { otg == n2vz;}
if (c1 == A) {otg == A;}

cout << otg <<endl;
return 0;
}
