1 #include <iostream> 2 #include <algorithm> 3 #include <cmath> 4 using namespace std; 5 6 typedef long long LL; 7 8 int main(){ 9 10 LL a, b; 11 while (cin >> a >> b){ 12 int t; 13 int ans = 0; 14 while (a){ 15 int t = a%b; 16 if (t == 1){ 17 ans++; 18 } 19 a = a/b; 20 } 21 cout << ans << endl; 22 } 23 24 return 0; 25 }