Finding cb number - failing two test cases

i am failing two test cases out of 9 in this ques. i could not find error in it
can you please help me out.
code-

import java.util.*;
public class Main{
public static void main(String[] args) throws Exception {
Scanner s = new Scanner(System.in);
int n =s.nextInt();
String str = s.next();
String ans = new String();
int count=0;
long i=0;
while(i < str.length()) {
long j=i+1;
while(j<= str.length()) {
ans = str.substring((int)i,(int)j);
long num = Long.parseLong(ans);
if(prime(num)) {
count++;
i=j;
}
j++;

		}
		i++;
		
	}
   System.out.println(count);
	
}

public static boolean prime(long num) {
	if(num==0||num==1){
		return false;}
	for(int i=2;i*i<=num;i++){
		if(num%i==0){
			return false;
			}
	}
	
	return true;
	
	
}

}

link- https://www.codepile.net/pile/7099Jy08

there can be cb number as well that are non prime for example
37*37 (it is not prime but it is cb number)
so correct it and then try to submit again