#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int p, g, n, c = 0, i;
  cin >> n >> p >> g;
  if (g <= p) {
    cout << g;
    return 0;
  }
  if (g > p && g <= n) {
    cout << p;
    return 0;
  } else {
    c = p - (g - n);
    if (g <= 0)
      cout << 0;
    else
      cout << c;
  }
  return 0;
}
