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