#include <bits/stdc++.h>
using namespace std;
template <class T>
inline void Swap(T &a, T &b) {
  a ^= b;
  b ^= a;
  a ^= b;
}
long long exp(long long a, unsigned long long b, unsigned long long mod) {
  long long res = 1;
  while (b) {
    if (b & 1) res = (res * a) % mod;
    a = (a * a) % mod;
    b >>= 1;
  }
  return res % mod;
}
long long modInverse(long long a, unsigned long long m) {
  return exp(a, m - 2, m);
}
int main() {
  cout << boolalpha;
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  int n, k, t;
  cin >> n >> k >> t;
  if (t <= k) {
    cout << t << endl;
  } else if (t <= n) {
    cout << k << endl;
  } else {
    cout << n + k - t << endl;
  }
  return 0;
}
