5 3
 1000 3
 777 17
 4 3
 2 2
 100 4
 10 4
 999 2
 6 4
 1 2
 17 3
 1 4
 26 8
 91 5
 1 3
 1000 2
 20 3
 9 4
 123 5
 1000 1000
 3 2
 3 3
 80 970
 1000 4
 1 1000

7
 1499
 825
 5
 3
 133
 13
 1997
 7
 1
 25
 1
 29
 113
 1
 1999
 29
 11
 153
 1001
 5
 4
 80
 1333
 1

#include <bits/stdc++.h>

typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;
#define debug(x) cerr << (#x) << " " << (x) <<" "<< endl
#define debug2(x, y) cerr << (#x) << " " << (x) <<" "<< (#y) << " " << (y) <<" "<< endl
#define debug3(x, y, z) cerr << (#x) << " " << (x) <<" "<< (#y) << " " << (y) <<" "<< (#z) << " " << (z) << endl
#define marwan ios::sync_with_stdio(0); cin.tie(0); ios_base::sync_with_stdio(0);
#define readwrite freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout);
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define f(a, b, c) for(ll a = b; a < c; a++)
#define vll vector<ll>
#define vld vector<ld>
#define vii vector<int>
#define pll pair<ll,ll>
#define pld pair<ld, ld>
#define vpll vector<pll>
#define vpld vector<pld>
#define cinvec(v, n) f(i, 0, n){ll a;cin>>a;v.pb(a);}
#define printvec(v, n) for (auto e: v) cout << e << " "; cout << endl;
#define pb push_back
#define RESET(a, b) memset(a, b, sizeof(a))
int INF = 1000000005;
long long INFF = 1000000000000000005LL;
double pi = acos(-1);
using namespace std;

int lcm(int a, int b) {
    return (a / __gcd(a, b) * b);
}

int main() {

    marwan
    ll a,b;
    cin>>a>>b;
    ll ans=a;

    while(a!=0)
    {
        a=a/b;
        ans++;
    }
    cout<<ans;



    return 0;
}