#include using namespace std; //repetition #define FOR(i,a,b) for(ll i=(a);i<(b);++i) #define rep(i, n) for(ll i = 0; i < (ll)(n); i++) //container util #define all(x) (x).begin(),(x).end() //typedef typedef long long ll; typedef vector VI; typedef vector VVI; typedef vector VLL; typedef vector VVLL; typedef vector VS; typedef pair PII; typedef pair PLL; //const value //const ll MOD = 1e9 + 7; //const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1}; //const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1}; //conversion inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;} inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;} template inline string toString(T x) {ostringstream sout;sout<> inp >> outq >> a; if(inp > outq){ ll ok = 0; // in ga ok ll ng = 1e9+1; // in ga ng while(abs(ok - ng ) > 1){ ll mid = (ok + ng) / 2; if(check(mid)) ok = mid; else ng = mid; } ll ans = max(ok-500,0); FOR(i,ok-499, ok + 500){ if(i < 1) continue; if(check(i)) ans++; } cout << ans << endl; }else if(inp == outq){ if(a > 0) cout << (ll)1e9 << endl; else cout << 0 << endl; }else{ cout << (ll) 1e9 << endl; } return 0; }