Finding cb numb

#include <bits/stdc++.h>

using namespace std;

bool check(long long int actnum)

{

int num[10]={2,3,5,7,11,13,17,19,23,29};

int c=0,p;

    if(actnum==0 || actnum==1)

{

   return false;

}

if(std::find(std::begin(num),std::end(num), actnum) != std::end(num))

{

    return true;

}

// reverse(b1.begin(), b1.end());

for (p = 0; p<10; p++)

{

if(actnum%num[p]==0)

{

    return false;

} }

if(p==10)

{

    return true;}

else

{

    return false;}}

using namespace std;

int main()

{

int n,p;

char a[1000];

cin>>n;



cin.ignore();

string s="";

cin.get(a,1000);

int num[10]={2,3,5,7,11,13,17,19,23,29};

int c=0;

for (int i = 0; a[i]!='\0'; i++)

{

 for (int j = i; a[j]!='\0'; j++)

{

    string b="";  

    for (int k = i; k<=j; k++)

{ 

    b=b+a[k];  

} 

long long int actnum=stoi(b),flag=0;

if(check(actnum))

{

    if(s.find(b)>10000)

    {

    s=s+b;

    c++;

  }}}}

cout<<c;

return 0;

}