#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
bool OkPrimeNum(long long num)
{
if(num<2)
return false;
for(int i = 2; i <= sqrt(num); ++i)
{
if(num%i == 0)
{
return false;
}
}
return true;
}
int solution(int n, int k) {
int answer = 0;
string num;
while(n)
{
int temp = n%k;
if(temp >= 10 && temp <=35)
{
num += temp + 55;
}
else {
num += temp + '0';
}
n /= k;
}
reverse(num.begin(), num.end());
long long result = 0;
for(int i = 0; i<num.size();++i)
{
if(num[i] != '0')
{
result *= 10;
result += (long long)(num[i] - '0');
}
else
{
if(OkPrimeNum(result))
{
answer++;
}
result = 0;
}
}
if(OkPrimeNum(result))
{
answer++;
}
return answer;
}