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