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