#include <bits/stdc++.h>
using namespace std;
int main() {
  unsigned long long int n, k, t;
  scanf("%I64d%I64d%I64d", &n, &k, &t);
  if (t <= k)
    printf("%I64d\n", t);
  else if (t > k && t <= n)
    printf("%I64d\n", k);
  else
    printf("%I64d\n", k + n - t);
  return 0;
}
