#include <bits/stdc++.h>
int read() {
  int v = 0, f = 1;
  char c = getchar();
  while (c < 48 || 57 < c) {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (48 <= c && c <= 57) v = (v << 3) + v + v + c - 48, c = getchar();
  return v * f;
}
using namespace std;
int main() {
  unsigned long long int n, k, t;
  n = read();
  k = read();
  t = read();
  if (t == n + k) {
    cout << "0" << '\n';
    return 0;
  } else if (t <= k) {
    cout << t << '\n';
    return 0;
  } else if (t < n && t > k)
    cout << k << '\n';
  else if (t > k) {
    cout << (n + k) - t << '\n';
  }
  return 0;
}
