#include <bits/stdc++.h>
using namespace std;
void c_p_c() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
int main() {
  c_p_c();
  int n, k, t;
  cin >> n >> k >> t;
  int standing = 0;
  if (t <= k)
    standing = t;
  else if (t <= n)
    standing = k;
  else if (t >= n + k)
    standing = 0;
  else
    standing = n + k - t;
  cout << standing << '\n';
}
