#define _USE_MATH_DEFINES #include using namespace std; #define FOR(i,m,n) for(int i=(m);i<(n);++i) #define REP(i,n) FOR(i,0,n) #define ALL(v) (v).begin(),(v).end() using ll = long long; constexpr int INF = 0x3f3f3f3f; constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL; constexpr double EPS = 1e-8; constexpr int MOD = 1000000007; // constexpr int MOD = 998244353; constexpr int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1}; constexpr int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1}; template inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; } template inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; } struct IOSetup { IOSetup() { std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); std::cout << fixed << setprecision(20); } } iosetup; int main() { ll n, k, m; cin >> n >> k >> m; double log10_n_EPS = log10(n) + EPS; unordered_map mp; ll a = 1; for (; log10(a) + log10(a + k) + log10(a + k * 2) < log10_n_EPS; ++a) { ll mul = a * (a + k); assert(mul <= n); ++mp[mul]; int b = 2; while (log10(mul) + log10(a + b * k) < log10_n_EPS) { mul *= a + b * k; if (mul > n) break; ++mp[mul]; ++b; } } ll lb = a - 1, ub = static_cast(ceil(sqrt(n))) + 1; while (ub - lb > 1) { ll mid = (lb + ub) >> 1; (log10(mid) + log10(mid + k) < log10_n_EPS && mid * (mid + k) <= n ? lb : ub) = mid; } ll l = a * (a + k), r = lb * (lb + k); auto check = [&](ll x) { if (lb < a || x < l || r < x) return false; if (x == l || x == r) return true; ll low = a + 1, high = min(lb, static_cast(ceil(sqrt(x))) + 1); while (high - low > 1) { ll mid = (low + high) >> 1; (mid * (mid + k) <= x ? low : high) = mid; } return low * (low + k) == x; }; ll ans = 0; if (m == 1) { for (auto [x, f] : mp) { if (check(x)) { --ans; } else if (f == 1) { ++ans; } } ans += max(lb - a + 1, 0LL); } else { for (auto [x, f] : mp) { if (f == m) { ans += !check(x); } else if (f + 1 == m) { ans += check(x); } } } cout << ans << '\n'; return 0; }