#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 3;
const long long mod = 1e9 + 7;
int main() {
  int n, k, t;
  cin >> n >> k >> t;
  if (t > n)
    cout << n + k - t;
  else if (t < k)
    cout << t;
  else
    cout << k;
  return 0;
}
