#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, t;
  scanf("%d%d%d", &n, &k, &t);
  int a = t / k, b = t % k, ans;
  if (t <= n)
    ans = b + (a ? k - b : 0);
  else {
    int r = t - n;
    a = n / k, b = n % k;
    ans = b + (a ? k - b : 0);
    ans -= r;
    if (ans < 0) ans = 0;
  }
  printf("%d\n", ans);
  return 0;
}
