public class Solution {

public int countPrimes(int num)

{

int counter =0 ;

boolean b[] = new boolean[num+1];

```
for(int i = 2; i < num; i++)
{
if(b[i] == false)
{
counter++;
{
for(int j = i*i; j<num; j =j+i )
{
b[j] = true;
}
}
}
}
return counter;
}
```

}