#include <bits/stdc++.h>
using namespace std;
int main() {
  long long a, b, c;
  while (cin >> a >> b >> c) {
    long long x = c % a;
    if (c < a) {
      cout << min(b, c) << endl;
    } else {
      cout << b - x << endl;
    }
  }
  return 0;
}
