#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int k, t;
  cin >> k >> t;
  if (t <= k) {
    cout << t << endl;
    return 0;
  } else if (t > n) {
    cout << k + n - t << endl;
    return 0;
  } else {
    cout << k << endl;
    return 0;
  }
}
