Please tell me what am i not considering

import java.util.*;
public class Main {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
sc.nextLine();
String s = sc.nextLine();
int count=0;
int c=0;
for(int i=c;i<n-1;i++)
{

		for(int j=i+1;j<n;j++)
		{
			
			int p = Integer.parseInt(s.substring(i,j));
			int flag=1;
			if(p==0 || p==1)
			{
				flag=0;
				continue;
			}
			else if(p==2)
			{
				flag=1;
			
			}
			else
			{
			for(int k=3;k<=Math.sqrt(p);k++)
			{
				if(p%k==0)
				{
					flag=0;
					break;
				}
			}
			}

			if(flag==1)
			{
				count++;
				c=j-1;
				break;
			}
		}
	}
	System.out.println(count);
}

}

@sarveshbibhuty dry run ur code for
8
88888888
u shd get 0 u get 7