#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, t;
  while (~scanf("%d%d%d", &n, &k, &t)) {
    if (t <= k) {
      cout << t << endl;
    }
    if (t > k && t <= n) {
      cout << k << endl;
    }
    if (t > n) {
      cout << n + k - t << endl;
    }
  }
  return 0;
}
