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