#include <iostream>
using namespace std;
int main () {


int n1;
char c1;
char A;
char B;
int n2;
char c2;
int k;
cout << "A:";
cin >> n1;
cout << "B:";
cin >> n2;
cin >> k;
if (n1 >= 1 && n1 <= 100 && n2 >= 1 && n2 <= 100 && 1 <= k && k <= n1 + n2 ) {
A = n1;
B = n2;


if (A > B && k > A) {
    cout << k - (A + B)/2 << endl;
}
if (B > A && k > B  ) {
cout << n1;
}
if (k < B && k < A && B > A) {
    cout << k;
}
if (k < B && k < A && B < A) {
      B = n1;
  A = n2;
    cout << 0;
}



}



























return 0;
}
