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