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