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