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