#include <bits/stdc++.h>
int main() {
  int i, j, k, l, n, m;
  while (~scanf("%d%d%d", &m, &n, &k)) {
    int sum = 0;
    if (k >= n + m)
      printf("0\n");
    else if (k <= n)
      printf("%d\n", k);
    else if (k > n && k <= m)
      printf("%d\n", n);
    else
      printf("%d\n", (n - (k - m)));
  }
}
