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