public static void main(String[] args){
		int[] p = new int[(int)1e6];
		for(int i=2;i<1e6;i++) p[i]=1;
		sieve(p);
		int count=0;
		for(int i=2;i<1e6;i++){
			if (p[i]==1){
				List<Integer> rotations = rotate(i);
				boolean circular = true;
				for(Integer k:rotations){
					if(p[k] == 0) circular = false;
				}
				if (circular == true) count++;
			}
		}
		System.out.println(count);
	}