N queen problem

bitset<30> col,d1,d2;
void solve(int r,int n,int ans){
if(r==n){
ans++;

    }
    for(int c=0;c<n;c++){
        if(!col[c] && !d1[r-c+n-1] && !d2[r+c]){
            col[c]=d1[r-c+n-1]=d2[r+c]=1;
            solve(r+1,n,ans);
            col[c]=d1[r-c+n-1]=d2[r+c]=0;
        }
    }
  
}

the above is code for finding all the possible config but i want to return that this is the possible number of config then where i have to change the code please tell me

Hey @sahudilip138
Please share complete code in IDE