#include <bits/stdc++.h>
using namespace std;
long long n, m, k, x, y, z;
int main() {
  cin >> n >> k >> m;
  if (m <= k)
    cout << m << endl;
  else if (m <= n)
    cout << k << endl;
  else {
    long long tmp = n + k;
    cout << tmp - m << endl;
  }
  return 0;
}
