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