Leonardo loves primes and created ${q}$ queries where each query takes the form of an integer, $n$. For each $n$, count the maximum number of distinct prime factors of any number in the inclusive range $[1,n]$.

Note: Recall that a prime number is only divisible by ${1}$ and itself, and ${1}$ is not a prime number.  

Example 

$n=100$  

The maximum number of distinct prime factors for values less than or equal to $100$ is $3$.One value with $3$ distinct prime factors is $30$. Another is ${42}$.    

Function Description  

Complete the primeCount function in the editor below.  

primeCount has the following parameters:  

int n: the inclusive limit of the range to check  

Returns  

int: the maximum number of distinct prime factors of any number in the inclusive range $\left[0-n\right]$.  

Input Format

The first line contains an integer, ${q}$, the number of queries. 

Each of the next ${q}$ lines contains a single integer, $n$.

Constraints

$1\leq q\leq10^5$  
$1\leq n\leq10^{18}$  

Sample Input
6
1
2
3
500
5000
10000000000

Sample Output
0
1
1
4
5
10

Explanation

${1}$ is not prime and its only factor is itself. 
$2$ has ${1}$ prime factor, $2$. 
The number $3$ has $1$ prime factor, $3$, $2$ has $1$ and $1$ has $0$ prime factors.
The product of the first four primes is $2\times3\times5\times7=210$.  While higher value primes may be a factor of some numbers, there will never be more than ${4}$ distinct prime factors for a number in this range.

Difficulty: EASY
Tags: Mathematics

Starter code:

Solutions:
q = input()
primes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59]
i = 0
while i < int(q):
	n = int(input())
	maxFacts = -1
	product = 1
	k = 0
	while n >= product:
		maxFacts += 1
		product = product * primes[k]
		k += 1
	print(maxFacts)
	i += 1


__Author__ = 'Deepak Singh Mehta...'

def primeSieve(limit):
	limitn = limit + 1
	not_prime = [False] * limitn
	primes = []
	for i in range(2, limitn):
		if not_prime[i]:
			continue
		for f in range(i * 2, limitn, i):
			not_prime[f] = True
		primes.append(i)
	return primes
primes = primeSieve(1000)
tests = int(input())
for _ in range(tests):
	n = int(input())
	comeon = 1
	cnt = 0
	for i in primes:
		comeon *= i
		if comeon > n:
			break
		cnt += 1
	print(cnt)


pr = []
np = []
sp = []
t = 1
for i in range(2, 10000):
	if t > 1000000000000000000:
		break
	if i not in np:
		pr.append(i)
		t *= i
		sp.append(t)
		for j in range(i * 2, 10000, i):
			np.append(j)
N = int(input())
for i in range(N):
	x = int(input())
	for (k, v) in enumerate(sp):
		if x < v:
			print(k)
			break


def primes2(n):
	(n, correction) = (n - n % 6 + 6, 2 - (n % 6 > 1))
	sieve = [True] * (n // 3)
	for i in range(1, int(n ** 0.5) // 3 + 1):
		if sieve[i]:
			k = 3 * i + 1 | 1
			sieve[k * k // 3::2 * k] = [False] * ((n // 6 - k * k // 6 - 1) // k + 1)
			sieve[k * (k - 2 * (i & 1) + 4) // 3::2 * k] = [False] * ((n // 6 - k * (k - 2 * (i & 1) + 4) // 6 - 1) // k + 1)
	return [2, 3] + [3 * i + 1 | 1 for i in range(1, n // 3 - correction) if sieve[i]]
prime_list = primes2(1000000)
cases = int(input())
for i in range(cases):
	shit = int(input())
	if shit == 1:
		print(0)
	elif shit < 6:
		print(1)
	else:
		count = 0
		hold = 1
		while hold <= shit:
			hold = hold * prime_list[count]
			count += 1
		if hold > shit:
			count -= 1
		print(count)


from math import sqrt
from itertools import count, islice

def isPrime(n):
	return n > 1 and all((n % i for i in islice(count(2), int(sqrt(n) - 1))))
q = eval(input())
factors = []
factor = 1
prime = 1
while factor < 10 ** 18:
	factors.insert(0, factor)
	prime += 1
	while not isPrime(prime):
		prime += 1
	factor *= prime
for i in range(q):
	n = eval(input())
	for (i, x) in enumerate(factors):
		if n >= x:
			print(len(factors) - i - 1)
			break


import bisect
import itertools
import operator

def main():
	primes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53]
	a = list(itertools.accumulate(primes, operator.mul))
	for i in range(int(input())):
		n = int(input())
		print(bisect.bisect(a, n))
main()


arr = [1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59]
q = int(input())
for i in range(q):
	n = int(input())
	m = 1
	for i in range(len(arr)):
		m *= arr[i]
		if m > n:
			print(i - 1)
			break


primes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 527, 529]
q = int(input())
data = 1
ind = 0
n = []
for x in range(q):
	n.append([int(input()), x])
n.sort()
for i in range(q):
	while n[i][0] >= data:
		data *= primes[ind]
		ind += 1
	(n[i][0], n[i][1]) = (n[i][1], ind - 1)
n.sort()
for z in n:
	print(z[1])


q = input()
primes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59]
i = 0
while i < int(q):
	n = int(input())
	maxFacs = -1
	prod = 1
	k = 0
	while n >= prod:
		maxFacs += 1
		prod = prod * primes[k]
		k += 1
	print(maxFacs)
	i += 1


import math
import sys
primes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]

def next_prime(n):
	if n < max(primes):
		return [x for (i, x) in enumerate(primes) if x > n][0]
	if n % 2 == 0:
		candidate = n + 1
	else:
		candidate = n + 2
	while is_prime(candidate):
		candidate += 2
	primes.append(candidate)
	return candidate

def is_prime(n):
	if n in primes:
		return n
	s = math.sqrt(n)
	div = 2
	while div < s:
		if n % div == 0:
			return False
		div = next_prime(div)
q = int(input())
for _ in range(q):
	n = int(input())
	i = 0
	product = 1
	p = 2
	while True:
		product *= p
		p = next_prime(p)
		if product > n:
			break
		i += 1
		print(i, product, file=sys.stderr)
	print(i)


def fromto(a, b, c):
	return range(a, b + 1, c)
mx = 10 ** 5
isPrime = [True] * (mx + 1)
for actual in fromto(2, int(mx ** 0.5), 1):
	if not isPrime[actual]:
		continue
	for tachar in fromto(actual * actual, mx, actual):
		isPrime[tachar] = False
primes = [x for x in fromto(2, mx, 1) if isPrime[x]]
q = int(input())
for i in range(q):
	n = int(input())
	fac = 0
	mul = 1
	while True:
		mul = mul * primes[fac]
		if mul > n:
			print(fac)
			break
		fac += 1


from bisect import bisect_right
MAXPRIME = 60
isprime = [True] * MAXPRIME
isprime[0] = isprime[1] = False
for i in range(2, 8):
	if isprime[i]:
		for j in range(i + i, MAXPRIME, i):
			isprime[j] = False
primes = [i for (i, x) in enumerate(isprime) if x]
primes_prod = primes[:]
for i in range(1, len(primes)):
	primes_prod[i] = primes_prod[i] * primes_prod[i - 1]
for _ in range(int(input())):
	n = int(input())
	print(bisect_right(primes_prod, n))


def max_factores_primos(n):
	prod = 1
	total = 0
	primos = [2]
	num = 2
	no_primo = True
	i = 0
	while True:
		prod *= primos[i]
		if prod > n:
			break
		total += 1
		no_primo = True
		while no_primo:
			num += 1
			for p in primos:
				if num % p == 0:
					break
				elif p == primos[-1]:
					primos.append(num)
					no_primo = False
					i += 1
	return total
q = int(input())
for caso in range(q):
	n = int(input())
	print(max_factores_primos(n))


q = int(input())
for i in range(0, q):
	n = int(input())
	list_prime = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53]
	p = 1
	for j in range(0, len(list_prime)):
		p = p * list_prime[j]
		if n < p:
			print(j)
			break


import math

def is_prime(a):
	return all((a % i for i in range(2, int(math.sqrt(a)) + 1)))

def generate_primes():
	primes = []
	primes.append(3)
	primes.append(5)
	i = 6
	while len(primes) < 15:
		if is_prime(i):
			primes.append(i)
		i += 1
	return primes
x = int(input())
for i in range(0, x):
	y = int(input())
	k = 2
	i = 0
	prim = generate_primes()
	while k <= y:
		k = k * prim[i]
		i += 1
	print(i)


import itertools

def gen_prime():
	yield 2
	yield 3
	yield 5
	D = {9: 3, 25: 5}
	MASK = (1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0)
	MODS = frozenset((1, 7, 11, 13, 17, 19, 23, 29))
	for n in itertools.compress(itertools.islice(itertools.count(7), 0, None, 2), itertools.cycle(MASK)):
		p = D.pop(n, None)
		if p is None:
			D[n ** 2] = n
			yield n
		else:
			q = n + 2 * p
			while q in D or q % 30 not in MODS:
				q += 2 * p
			D[q] = p
for tmp in range(int(input())):
	x = 1
	c = 0
	z = int(input())
	g = gen_prime()
	while True:
		x *= next(g)
		if x <= z:
			c += 1
		else:
			break
	print(c)


t = int(input())
while t:
	t -= 1
	n = int(input())
	if n < 2:
		print(0)
	elif n < 2 * 3:
		print(1)
	elif n < 2 * 3 * 5:
		print(2)
	elif n < 2 * 3 * 5 * 7:
		print(3)
	elif n < 2 * 3 * 5 * 7 * 11:
		print(4)
	elif n < 2 * 3 * 5 * 7 * 11 * 13:
		print(5)
	elif n < 2 * 3 * 5 * 7 * 11 * 13 * 17:
		print(6)
	elif n < 2 * 3 * 5 * 7 * 11 * 13 * 17 * 19:
		print(7)
	elif n < 2 * 3 * 5 * 7 * 11 * 13 * 17 * 19 * 23:
		print(8)
	elif n < 2 * 3 * 5 * 7 * 11 * 13 * 17 * 19 * 23 * 29:
		print(9)
	elif n < 2 * 3 * 5 * 7 * 11 * 13 * 17 * 19 * 23 * 29 * 31:
		print(10)
	elif n < 2 * 3 * 5 * 7 * 11 * 13 * 17 * 19 * 23 * 29 * 31 * 37:
		print(11)
	elif n < 2 * 3 * 5 * 7 * 11 * 13 * 17 * 19 * 23 * 29 * 31 * 37 * 41:
		print(12)
	elif n < 2 * 3 * 5 * 7 * 11 * 13 * 17 * 19 * 23 * 29 * 31 * 37 * 41 * 43:
		print(13)
	elif n < 2 * 3 * 5 * 7 * 11 * 13 * 17 * 19 * 23 * 29 * 31 * 37 * 41 * 43 * 47:
		print(14)
	elif n < 2 * 3 * 5 * 7 * 11 * 13 * 17 * 19 * 23 * 29 * 31 * 37 * 41 * 43 * 47 * 53:
		print(15)


q = int(input().strip())
primos = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]
for i in range(q):
	n = int(input().strip())
	m = 1
	aux = 0
	for j in range(len(primos)):
		if m * primos[j] <= n:
			m *= primos[j]
			aux = j + 1
	print(aux)


def prime(i, primes):
	for prime in primes:
		if not (i == prime or i % prime):
			return False
	primes += [i]
	return i

def historic(n):
	primes = []
	(i, p) = (2, 0)
	while True:
		if prime(i, primes):
			p += 1
			if p == n:
				return primes
		i += 1
np = 18
H = historic(np)
M = [1]
m = 1
for k in range(np):
	m *= H[k]
	M += [m]
q = int(input())
for j in range(q):
	n = int(input())
	k = 0
	while M[k] <= n:
		k += 1
	print(k - 1)


def rwh_primes1(n):
	sieve = [True] * (n // 2)
	for i in range(3, int(n ** 0.5) + 1, 2):
		if sieve[i // 2]:
			sieve[i * i // 2::i] = [False] * ((n - i * i - 1) // (2 * i) + 1)
	return [2] + [2 * i + 1 for i in range(1, n // 2) if sieve[i]]
queries = [int(input()) for _ in range(int(input()))]
m = max(queries)
primes = rwh_primes1(5 * 10 ** 7)
for q in queries:
	p = 1
	i = 0
	while p <= q and i < len(primes):
		p *= primes[i]
		i += 1
	print(i - 1)


prime_factors = []

def compute_next_prime():
	x = 2
	if len(prime_factors) > 0:
		x = prime_factors[-1] + 1
	prime_found = False
	while not prime_found:
		max_factor = x ** 0.5
		prime = True
		for factor in prime_factors:
			if factor > max_factor:
				break
			if x % factor == 0:
				prime = False
				break
		if prime:
			prime_factors.append(x)
			prime_found = True
		x += 1
max_prime_factors = [1]

def find_max_prime_factors(n):
	max_factors = 0
	while max_prime_factors[-1] < n:
		compute_next_prime()
		product = max_prime_factors[-1] * prime_factors[-1]
		max_prime_factors.append(product)
		max_factors = len(max_prime_factors) - 2
	while max_factors + 1 < len(max_prime_factors) and max_prime_factors[max_factors + 1] <= n:
		max_factors += 1
	return max_factors
q = int(input().strip())
for i in range(q):
	n = int(input().strip())
	print(find_max_prime_factors(n))


def get_primes(n):
	numbers = set(range(n, 1, -1))
	primes = []
	while numbers:
		p = numbers.pop()
		primes.append(p)
		numbers.difference_update(set(range(p * 2, n + 1, p)))
	return primes
a = get_primes(100)
product = 1
n = int(input())
for _ in range(n):
	q = int(input())
	if q == 1:
		print(0)
	elif q == 2:
		print(1)
	else:
		product = 1
		for x in range(len(a)):
			product *= a[x]
			if product > q:
				print(x)
				break


primes = (2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61)
peaks = [(0, 0)]
product = 1
for (i, p) in enumerate(primes):
	product *= p
	tup = (product, i)
	peaks.append(tup)

def get_prime_count(n):
	return next((b for (a, b) in peaks if a > n))
N = int(input())
for i in range(N):
	print(get_prime_count(int(input())))


from math import sqrt

def primeSieve(size):
	sieve_list = [True] * (size + 1)
	sieve_list[0] = False
	sieve_list[1] = False
	for i in range(2, int(sqrt(size + 1)) + 1):
		if sieve_list[i] == True:
			pointer = 2 * i
			while pointer < size + 1:
				sieve_list[pointer] = False
				pointer += i
	primes = []
	for i in range(size + 1):
		if sieve_list[i] == True:
			primes.append(i)
	return primes
p = primeSieve(70)
q = int(input())
l = []
for _ in range(q):
	l.append(int(input()))
interval = []
z = 1
for i in p:
	if z > 10 ** 18:
		break
	z *= i
	interval.append(z)
for x in l:
	for y in interval:
		if y > x:
			print(interval.index(y))
			break


import sys
import itertools
import bisect

class PrimeGenerator(object):

	def __init__(self):
		self._primes = [2, 3, 5, 7, 11, 13]
		self._idx = 0

	def __iter__(self):
		return self

	def __next__(self):
		if self._idx < len(self._primes):
			next_prime = self._primes[self._idx]
		else:
			max_prime = self._primes[-1]
			for p in itertools.count(max_prime + 2, 2):
				p_prime = True
				for p0 in self._primes:
					if p % p0 == 0:
						p_prime = False
						break
				if p_prime:
					next_prime = p
					break
			self._primes.append(next_prime)
		self._idx += 1
		return next_prime
prime_gen = PrimeGenerator()
prime_prods = []

def max_prime(n):
	if n in (0, 1):
		return 0
	if len(prime_prods) == 0:
		acc = 1
		for i in range(10):
			acc *= next(prime_gen)
			prime_prods.append(acc)
	idx = bisect.bisect(prime_prods, n)
	if idx >= len(prime_prods):
		prod = prime_prods[-1]
		while prod < n:
			prod *= next(prime_gen)
			prime_prods.append(prod)
		idx = bisect.bisect(prime_prods, n)
	return idx
q = int(input().strip())
for i in range(q):
	n = int(input().strip())
	print(max_prime(n))


from bisect import bisect
pcum = [2, 6, 30, 210, 2310, 30030, 510510, 9699690, 223092870, 6469693230, 200560490130, 7420738134810, 304250263527210, 13082761331670030, 614889782588491410]
print(*(bisect(pcum, int(input())) for _ in range(int(input()))), sep='\n')


import math
primes = [2, 3]

def nth_prime(n):
	count = len(primes)
	if n < count:
		return primes[n]
	i = primes[count - 1] + 2
	while n >= count:
		for p in range(count):
			if not i % primes[p]:
				break
			if primes[p] ** 2 > i:
				primes.append(i)
				count += 1
				break
		i += 2
	return primes[n]

def unique_prime_factors(n):
	product = 1
	factors = 1
	while True:
		product *= nth_prime(factors - 1)
		if product > n:
			return factors - 1
		factors += 1
q = int(input().strip())
for _ in range(q):
	n = int(input().strip())
	upf = unique_prime_factors(n)
	print(upf)


import functools
q = int(input())
for i in range(0, q):
	n = int(input())
	primes = [2]
	product = 1
	l = 3
	while product <= n:
		if all((l % q != 0 for q in primes)):
			primes.append(l)
		l = l + 2
		product = functools.reduce(lambda x, y: x * y, primes)
	if n == 1:
		print(0)
	else:
		print(len(primes) - 1)


for i in range(int(input())):
	v = int(input())
	if v < 2:
		print(0)
		continue
	primes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59]
	n = 0
	k = 1
	while k <= v:
		k *= primes.pop(0)
		if k <= v:
			n += 1
	print(n)


q = int(input())
while q != 0:
	n = int(input())
	m = n
	i = 2
	mul = 1
	count = 0
	while m != 0:
		if n == 0 or n == 1:
			count = 0
			break
		if n == 2:
			count = 1
			break
		for k in range(2, i + 1):
			if i % k == 0:
				break
		if k == i:
			mul = mul * i
			count = count + 1
		if mul == n:
			break
		if mul > n:
			count = count - 1
			break
		i = i + 1
		m = m - 1
	q = q - 1
	print(count)


from functools import reduce
lp = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349]

def primes_short(listLength):
	return lp[:listLength]

def find_primes(top):
	for i in range(1, len(lp)):
		if reduce(lambda x, y: x * y, primes_short(i)) > top:
			return i - 1
	return 0
for i in range(int(input())):
	fact = find_primes(int(input()))
	print(fact)


import math
primes = [2, 3, 5, 7, 11, 13, 17]

def g(n):
	if n == 1:
		return 0
	primes = [2, 3, 5, 7, 11, 13, 17]
	mult = 1
	i = 1
	for prime in primes:
		mult *= prime
		if mult > n:
			return i - 1
		if mult == n:
			return i
		i += 1
	last = primes[len(primes) - 1]
	while True:
		last += 1
		if FPrime(last):
			primes.append(last)
			mult *= last
			i += 1
			if mult > n:
				return i - 2
			if mult == n:
				return i - 1

def FPrime(n):
	root = math.sqrt(n)
	if n < 2:
		return False
	if n == 2:
		return True
	for i in range(2, math.ceil(root + 1)):
		if n % i == 0:
			return False
	return True
T = int(input().strip())
for a0 in range(T):
	print(g(int(input().strip())))


import sys
primes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53]

def do(n):
	if n == 1:
		return 0
	elif n < 6:
		return 1
	ret = 2
	a = 6
	while a <= n:
		a *= primes[ret]
		ret += 1
	return ret - 1

def main():
	q = int(input())
	queries = []
	for i in range(q):
		temp = int(input())
		queries.append(temp)
	for i in range(q):
		print(do(queries[i]))
main()


import sys
primes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]
tmp = 1
for (i, p) in enumerate(primes):
	tmp *= p
	primes[i] = tmp
q = int(sys.stdin.readline())
for i in range(0, q):
	n = int(sys.stdin.readline())
	i = 0
	while primes[i] <= n:
		i += 1
	print(i)


import sys
import math
q = int(input().strip())
for i in range(q):
	n = int(input().strip())
	if n <= 1:
		print(0)
		continue
	else:
		fact = 1
		count = 0
		lst = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53]
		for item in lst:
			fact = fact * item
			if fact <= n:
				count += 1
			else:
				break
		print(count)


q = int(input())
primes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73]
product = 1
table = []
for p in primes:
	product *= p
	table.append(product)
for i in range(q):
	n = int(input())
	for i in range(len(table)):
		if n < table[i]:
			print(i)
			break


PRIMORIALS = [1, 2, 6, 30, 210, 2310, 30030, 510510, 9699690, 223092870, 6469693230, 200560490130, 7420738134810, 304250263527210, 13082761331670030, 614889782588491410]

def maxOmega(n):
	tmp = [i for (i, p) in enumerate(PRIMORIALS) if p <= n]
	return tmp[-1]

def main():
	q = int(input())
	for _ in range(q):
		n = int(input())
		print(maxOmega(n))
main()


import math

def prime(n):
	return [d for d in range(1, n) if all((d % i != 0 for i in range(2, int(math.sqrt(d) + 1))))]

def max_count_prime(num):
	flag = []
	if num == 2:
		print(1)
		return
	p1 = prime(54)
	j = p1[0]
	for i in p1:
		i = i * j
		flag.append(i)
		j = i
		if i > num:
			break
	print(len(flag) - 2)
x = int(input())
while x > 0:
	y = int(input())
	max_count_prime(y)
	x -= 1


from math import sqrt

def numPrimeToN_Inclusive(n):
	if n <= 1:
		return 0
	sqrt_n = int(sqrt(n))
	factors = [n]
	for i in range(2, sqrt_n + 1, 1):
		if n % i == 0:
			factors.append(i)
			factors.append(n // i)
	factors = list(set(factors))
	primeFactors = [i for i in factors if isprime(i)]
	return len(primeFactors)

def isfactor(n, f):
	if n % f == 0:
		return True
	return False

def isprime(n):
	n = abs(int(n))
	if n < 2:
		return False
	if n == 2:
		return True
	if not n & 1:
		return False
	for x in range(3, int(n ** 0.5) + 1, 2):
		if n % x == 0:
			return False
	return True

def listLittlestUniqueNumOfPrimes(n):
	littlestList = []
	primeList = []
	primeProduct = 1
	done = False
	cnt = 2
	while not done:
		if isprime(cnt):
			primeProduct *= cnt
			if primeProduct <= n:
				primeList.append(cnt)
			else:
				done = True
				break
		cnt += 1
	return primeList

def main():
	q = int(input())
	for i in range(q):
		n = int(input())
		print(len(listLittlestUniqueNumOfPrimes(n)))

def oldMain():
	q = int(input())
	for i in range(q):
		try:
			n = int(input().strip())
			best = 0
			for i in range(n + 1):
				a = numPrimeToN_Inclusive(i)
				if a > best:
					best = a
			print(best)
		except:
			print(0)
main()


p01 = 6
p02 = 30
p03 = 210
p04 = 2310
p05 = 30030
p06 = 510510
p07 = 9699690
p08 = 223092870
p09 = 6469693230
p10 = 200560490130
p11 = 200560490130 * 37
p12 = 200560490130 * 37 * 41
p13 = 200560490130 * 37 * 41 * 43
p14 = 200560490130 * 37 * 41 * 43 * 47
p15 = 200560490130 * 37 * 41 * 43 * 47 * 53
q = int(input().strip())
for i in range(q):
	n = int(input().strip())
	if n < 2:
		print(0)
	elif n < p01:
		print(1)
	elif n < p02:
		print(2)
	elif n < p03:
		print(3)
	elif n < p04:
		print(4)
	elif n < p05:
		print(5)
	elif n < p06:
		print(6)
	elif n < p07:
		print(7)
	elif n < p08:
		print(8)
	elif n < p09:
		print(9)
	elif n < p10:
		print(10)
	elif n < p11:
		print(11)
	elif n < p12:
		print(12)
	elif n < p13:
		print(13)
	elif n < p14:
		print(14)
	elif n < p15:
		print(15)


import math
query = int(input())
for q in range(query):
	targ = int(input())
	calc = 1
	ans = 0
	for num in range(2, targ + 2):
		if calc > targ:
			ans -= 1
			break
		elif calc == targ:
			break
		else:
			for t in range(2, math.floor(math.sqrt(num)) + 1):
				if num % t == 0:
					break
			else:
				calc *= num
				ans += 1
	print(ans)


q = int(input())
queries = [int(input()) for _ in range(q)]

def genPrimes():
	D = {}
	q = 2
	while True:
		if q not in D:
			yield q
			D[q * q] = [q]
		else:
			for p in D[q]:
				D.setdefault(p + q, []).append(p)
			del D[q]
		q += 1
qSorted = sorted(queries)
ans = {}
prod = 1
total = 0
it = genPrimes()
p = next(it)
for q in qSorted:
	while prod * p <= q:
		prod *= p
		total += 1
		p = next(it)
	ans[q] = total
print(*[ans[n] for n in queries], sep='\n')


primes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997, 1009, 1013, 1019, 1021, 1031, 1033, 1039, 1049, 1051, 1061, 1063, 1069, 1087, 1091, 1093, 1097, 1103, 1109, 1117, 1123, 1129, 1151, 1153, 1163, 1171, 1181, 1187, 1193, 1201, 1213, 1217, 1223, 1229, 1231, 1237, 1249, 1259, 1277, 1279, 1283, 1289, 1291, 1297, 1301, 1303, 1307, 1319, 1321, 1327, 1361, 1367, 1373, 1381, 1399, 1409, 1423, 1427, 1429, 1433, 1439, 1447, 1451, 1453, 1459, 1471, 1481, 1483, 1487, 1489, 1493, 1499, 1511, 1523, 1531, 1543, 1549, 1553, 1559, 1567, 1571, 1579, 1583, 1597, 1601, 1607, 1609, 1613, 1619, 1621, 1627, 1637, 1657, 1663, 1667, 1669, 1693, 1697, 1699, 1709, 1721, 1723, 1733, 1741, 1747, 1753, 1759, 1777, 1783, 1787, 1789, 1801, 1811, 1823, 1831, 1847, 1861, 1867, 1871, 1873, 1877, 1879, 1889, 1901, 1907, 1913, 1931, 1933, 1949, 1951, 1973, 1979, 1987, 1993, 1997, 1999, 2003, 2011, 2017, 2027, 2029, 2039, 2053, 2063, 2069, 2081, 2083, 2087, 2089, 2099, 2111, 2113, 2129, 2131, 2137, 2141, 2143, 2153, 2161, 2179, 2203, 2207, 2213, 2221, 2237, 2239, 2243, 2251, 2267, 2269, 2273, 2281, 2287, 2293, 2297, 2309, 2311, 2333, 2339, 2341, 2347, 2351, 2357, 2371, 2377, 2381, 2383, 2389, 2393, 2399, 2411, 2417, 2423, 2437, 2441, 2447, 2459, 2467, 2473, 2477, 2503, 2521, 2531, 2539, 2543, 2549, 2551, 2557, 2579, 2591, 2593, 2609, 2617, 2621, 2633, 2647, 2657, 2659, 2663, 2671, 2677, 2683, 2687, 2689, 2693, 2699, 2707, 2711, 2713, 2719, 2729, 2731, 2741, 2749, 2753, 2767, 2777, 2789, 2791, 2797, 2801, 2803, 2819, 2833, 2837, 2843, 2851, 2857, 2861, 2879, 2887, 2897, 2903, 2909, 2917, 2927, 2939, 2953, 2957, 2963, 2969, 2971, 2999, 3001, 3011, 3019, 3023, 3037, 3041, 3049, 3061, 3067, 3079, 3083, 3089, 3109, 3119, 3121, 3137, 3163, 3167, 3169, 3181, 3187, 3191, 3203, 3209, 3217, 3221, 3229, 3251, 3253, 3257, 3259, 3271, 3299, 3301, 3307, 3313, 3319, 3323, 3329, 3331, 3343, 3347, 3359, 3361, 3371, 3373, 3389, 3391, 3407, 3413, 3433, 3449, 3457, 3461, 3463, 3467, 3469, 3491, 3499, 3511, 3517, 3527, 3529, 3533, 3539, 3541, 3547, 3557, 3559, 3571, 3581, 3583, 3593, 3607, 3613, 3617, 3623, 3631, 3637, 3643, 3659, 3671, 3673, 3677, 3691, 3697, 3701, 3709, 3719, 3727, 3733, 3739, 3761, 3767, 3769, 3779, 3793, 3797, 3803, 3821, 3823, 3833, 3847, 3851, 3853, 3863, 3877, 3881, 3889, 3907, 3911, 3917, 3919, 3923, 3929, 3931, 3943, 3947, 3967, 3989, 4001, 4003, 4007, 4013, 4019, 4021, 4027, 4049, 4051, 4057, 4073, 4079, 4091, 4093, 4099, 4111, 4127, 4129, 4133, 4139, 4153, 4157, 4159, 4177, 4201, 4211, 4217, 4219, 4229, 4231, 4241, 4243, 4253, 4259, 4261, 4271, 4273, 4283, 4289, 4297, 4327, 4337, 4339, 4349, 4357, 4363, 4373, 4391, 4397, 4409, 4421, 4423, 4441, 4447, 4451, 4457, 4463, 4481, 4483, 4493, 4507, 4513, 4517, 4519, 4523, 4547, 4549, 4561, 4567, 4583, 4591, 4597, 4603, 4621, 4637, 4639, 4643, 4649, 4651, 4657, 4663, 4673, 4679, 4691, 4703, 4721, 4723, 4729, 4733, 4751, 4759, 4783, 4787, 4789, 4793, 4799, 4801, 4813, 4817, 4831, 4861, 4871, 4877, 4889, 4903, 4909, 4919, 4931, 4933, 4937, 4943, 4951, 4957, 4967, 4969, 4973, 4987, 4993, 4999, 5003, 5009, 5011, 5021, 5023, 5039, 5051, 5059, 5077, 5081, 5087, 5099, 5101, 5107, 5113, 5119, 5147, 5153, 5167, 5171, 5179, 5189, 5197, 5209, 5227, 5231, 5233, 5237, 5261, 5273, 5279, 5281, 5297, 5303, 5309, 5323, 5333, 5347, 5351, 5381, 5387, 5393, 5399, 5407, 5413, 5417, 5419, 5431, 5437, 5441, 5443, 5449, 5471, 5477, 5479, 5483, 5501, 5503, 5507, 5519, 5521, 5527, 5531, 5557, 5563, 5569, 5573, 5581, 5591, 5623, 5639, 5641, 5647, 5651, 5653, 5657, 5659, 5669, 5683, 5689, 5693, 5701, 5711, 5717, 5737, 5741, 5743, 5749, 5779, 5783, 5791, 5801, 5807, 5813, 5821, 5827, 5839, 5843, 5849, 5851, 5857, 5861, 5867, 5869, 5879, 5881, 5897, 5903, 5923, 5927, 5939, 5953, 5981, 5987, 6007, 6011, 6029, 6037, 6043, 6047, 6053, 6067, 6073, 6079, 6089, 6091, 6101, 6113, 6121, 6131, 6133, 6143, 6151, 6163, 6173, 6197, 6199, 6203, 6211, 6217, 6221, 6229, 6247, 6257, 6263, 6269, 6271, 6277, 6287, 6299, 6301, 6311, 6317, 6323, 6329, 6337, 6343, 6353, 6359, 6361, 6367, 6373, 6379, 6389, 6397, 6421, 6427, 6449, 6451, 6469, 6473, 6481, 6491, 6521, 6529, 6547, 6551, 6553, 6563, 6569, 6571, 6577, 6581, 6599, 6607, 6619, 6637, 6653, 6659, 6661, 6673, 6679, 6689, 6691, 6701, 6703, 6709, 6719, 6733, 6737, 6761, 6763, 6779, 6781, 6791, 6793, 6803, 6823, 6827, 6829, 6833, 6841, 6857, 6863, 6869, 6871, 6883, 6899, 6907, 6911, 6917, 6947, 6949, 6959, 6961, 6967, 6971, 6977, 6983, 6991, 6997, 7001, 7013, 7019, 7027, 7039, 7043, 7057, 7069, 7079, 7103, 7109, 7121, 7127, 7129, 7151, 7159, 7177, 7187, 7193, 7207, 7211, 7213, 7219, 7229, 7237, 7243, 7247, 7253, 7283, 7297, 7307, 7309, 7321, 7331, 7333, 7349, 7351, 7369, 7393, 7411, 7417, 7433, 7451, 7457, 7459, 7477, 7481, 7487, 7489, 7499, 7507, 7517, 7523, 7529, 7537, 7541, 7547, 7549, 7559, 7561, 7573, 7577, 7583, 7589, 7591, 7603, 7607, 7621, 7639, 7643, 7649, 7669, 7673, 7681, 7687, 7691, 7699, 7703, 7717, 7723, 7727, 7741, 7753, 7757, 7759, 7789, 7793, 7817, 7823, 7829, 7841, 7853, 7867, 7873, 7877, 7879, 7883, 7901, 7907, 7919, 7927, 7933, 7937, 7949, 7951, 7963, 7993, 8009, 8011, 8017, 8039, 8053, 8059, 8069, 8081, 8087, 8089, 8093, 8101, 8111, 8117, 8123, 8147, 8161, 8167, 8171, 8179, 8191, 8209, 8219, 8221, 8231, 8233, 8237, 8243, 8263, 8269, 8273, 8287, 8291, 8293, 8297, 8311, 8317, 8329, 8353, 8363, 8369, 8377, 8387, 8389, 8419, 8423, 8429, 8431, 8443, 8447, 8461, 8467, 8501, 8513, 8521, 8527, 8537, 8539, 8543, 8563, 8573, 8581, 8597, 8599, 8609, 8623, 8627, 8629, 8641, 8647, 8663, 8669, 8677, 8681, 8689, 8693, 8699, 8707, 8713, 8719, 8731, 8737, 8741, 8747, 8753, 8761, 8779, 8783, 8803, 8807, 8819, 8821, 8831, 8837, 8839, 8849, 8861, 8863, 8867, 8887, 8893, 8923, 8929, 8933, 8941, 8951, 8963, 8969, 8971, 8999, 9001, 9007, 9011, 9013, 9029, 9041, 9043, 9049, 9059, 9067, 9091, 9103, 9109, 9127, 9133, 9137, 9151, 9157, 9161, 9173, 9181, 9187, 9199, 9203, 9209, 9221, 9227, 9239, 9241, 9257, 9277, 9281, 9283, 9293, 9311, 9319, 9323, 9337, 9341, 9343, 9349, 9371, 9377, 9391, 9397, 9403, 9413, 9419, 9421, 9431, 9433, 9437, 9439, 9461, 9463, 9467, 9473, 9479, 9491, 9497, 9511, 9521, 9533, 9539, 9547, 9551, 9587, 9601, 9613, 9619, 9623, 9629, 9631, 9643, 9649, 9661, 9677, 9679, 9689, 9697, 9719, 9721, 9733, 9739, 9743, 9749, 9767, 9769, 9781, 9787, 9791, 9803, 9811, 9817, 9829, 9833, 9839, 9851, 9857, 9859, 9871, 9883, 9887, 9901, 9907, 9923, 9929, 9931, 9941, 9949, 9967, 9973]
q = int(input())
for _ in range(q):
	n = int(input())
	i = 0
	tmp = primes[i]
	while tmp <= n:
		i += 1
		tmp = tmp * primes[i]
	print(i)


import math

def isPrime(num):
	if num < 2:
		return False
	for i in range(2, int(math.sqrt(num)) + 1):
		if num % i == 0:
			return False
	return True

def primeSieve(sieveSize):
	sieve = [True] * sieveSize
	sieve[0] = False
	sieve[1] = False
	for i in range(2, int(math.sqrt(sieveSize)) + 1):
		pointer = i * 2
		while pointer < sieveSize:
			sieve[pointer] = False
			pointer += i
	primes = []
	for i in range(sieveSize):
		if sieve[i] == True:
			primes.append(i)
	return primes

def main():
	primes = primeSieve(1000)
	q = int(input())
	for bla in range(q):
		num = 1
		cont = 0
		n = int(input())
		while num <= n:
			num = num * primes[cont]
			cont += 1
		print(cont - 1)
main()


import math

def sieve(n):
	np1 = n + 1
	s = list(range(np1))
	s[1] = 0
	sqrtn = int(round(n ** 0.5))
	for i in range(2, sqrtn + 1):
		if s[i]:
			s[i * i:np1:i] = [0] * int(math.ceil((np1 - i * i) / i))
	return filter(None, s)
primes = list(sieve(100))
primes.sort()
for __ in range(int(input())):
	n = int(input())
	if n == 1:
		print(0)
		continue
	res = primes[0]
	for i in range(1, len(primes)):
		res *= primes[i]
		if res > n:
			print(i)
			break
		elif res == n:
			print(i + 1)
			break


import sys
import math

def sieve(num):
	a = [True] * num
	(a[0], a[1]) = (False, False)
	for i in range(2, int(math.sqrt(num))):
		if a[i] == True:
			for j in range(i * i, num, i):
				a[j] = False
	lst = []
	for i in range(num):
		if a[i] == True:
			lst.append(i)
	return lst
q = int(input().strip())
for i in range(q):
	n = int(input().strip())
	if n <= 1:
		print(0)
		continue
	else:
		fact = 1
		count = 0
		lst = sieve(55)
		for item in lst:
			fact = fact * item
			if fact <= n:
				count += 1
			else:
				break
		print(count)


def primes(n):
	sieve = [True] * n
	for i in range(3, int(n ** 0.5) + 1, 2):
		if sieve[i]:
			sieve[i * i::2 * i] = [False] * ((n - i * i - 1) // (2 * i) + 1)
	return [2] + [i for i in range(3, n, 2) if sieve[i]]
pr = primes(100)

def factors(n):
	if n < 2:
		return 0
	else:
		val = 1
		sum = 0
		for i in pr:
			if i * val <= n:
				val = val * i
				sum = sum + 1
		return sum
q = int(input())
for i in range(0, q):
	print(factors(int(input())))


p = [2, 6, 30, 210, 2310, 30030, 510510, 9699690, 223092870, 6469693230, 200560490130, 7420738134810, 304250263527210, 13082761331670030, 614889782588491410, 32589158477190044730]
q = int(input())
for i in range(q):
	n = int(input())
	j = 0
	while p[j] <= n:
		j += 1
	print(j)


n = int(input())
inters = []

def isprime(n):
	if n == 2:
		return True
	if n == 3:
		return True
	if n % 2 == 0:
		return False
	if n % 3 == 0:
		return False
	i = 5
	w = 2
	while i * i <= n:
		if n % i == 0:
			return False
		i += w
		w = 6 - w
	return True

def countPrimes(mx):
	primes = [2]
	prds = [2]
	k = 3
	while k <= mx / prds[len(prds) - 1]:
		if isprime(k):
			primes.append(k)
			prds.append(prds[len(prds) - 1] * k)
		k += 2
	return prds
for i in range(n):
	inters.append(int(input()))
mx = max(inters)
prds = countPrimes(mx)
for item in inters:
	if item <= 1:
		print(0)
	elif item == 2:
		print(1)
	else:
		for i in range(len(prds) - 1):
			if item >= prds[i] and item < prds[i + 1]:
				print(i + 1)
		if item >= prds[len(prds) - 1]:
			print(len(prds))


import bisect
import itertools
import operator

def main():
	primes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53]
	a = list(itertools.accumulate(primes, operator.mul))
	for i in range(int(input())):
		n = int(input())
		print(bisect.bisect(a, n))
main()


from functools import reduce
P = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59]
Q = int(input())
for q in range(Q):
	N = int(input())
	s = 1
	for (i, p) in enumerate(P):
		s *= p
		if s > N:
			break
	print(i)


from math import *

def is_prime(n):
	ctr = 0
	i = 2
	while i <= ceil(sqrt(n)):
		if n % i == 0:
			ctr += 1
		i += 1
	if n == 1:
		return False
	elif ctr == 0 or n == 2 or n == 3:
		return True
	else:
		return False

def upf(n):
	if n == 1:
		return 0
	elif n < 6:
		return 1
	prime_product = 2
	ctr = 1
	for i in range(3, n, 2):
		if is_prime(i):
			prime_product *= i
			if prime_product <= n:
				ctr += 1
			else:
				break
	return ctr
q = int(input())
for i in range(q):
	n = int(input())
	print(upf(n))


def max_factores_primos(n):
	prod = 1
	total = 0
	primos = [2]
	num = 2
	no_primo = True
	i = 0
	while True:
		prod *= primos[i]
		if prod > n:
			break
		total += 1
		no_primo = True
		while no_primo:
			num += 1
			for p in primos:
				if num % p == 0:
					break
				elif p == primos[-1]:
					primos.append(num)
					no_primo = False
					i += 1
	return total
q = int(input())
for caso in range(q):
	n = int(input())
	print(max_factores_primos(n))


import math

def is_prime(x):
	for i in range(2, int(math.sqrt(x)) + 1):
		if x % i == 0:
			return False
	return True
for _ in range(int(input())):
	num = int(input())
	count = 0
	if num == 1:
		print(0)
	elif num == 2:
		print(1)
	else:
		for i in range(2, num):
			if is_prime(i):
				num = num // i
				if num < 1:
					break
				count += 1
		print(count)


for index in range(int(input())):
	N = int(input())
	product = 2
	currentprime = 3
	numprimes = 0
	while product <= N:
		nextprime = False
		while nextprime == False:
			composite = False
			limit = int(currentprime ** 0.5) + 1
			for i in range(2, limit):
				if currentprime % i == 0:
					composite = True
					break
			if composite == False:
				nextprime = True
				product = product * currentprime
				numprimes = numprimes + 1
			currentprime = currentprime + 1
	if N == 1:
		numprimes = 0
	if N == 2:
		numprimes = 1
	print(numprimes)


from bisect import bisect
primes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47]
prods = [1]
for p in primes:
	prods.append(p * prods[-1])
for n in range(int(input())):
	q = int(input())
	i = bisect(prods, q)
	print(i - 1)


T = int(input())
primes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53]
for i in range(T):
	n = int(input())
	idx = 0
	prod = 2
	while n >= prod:
		idx += 1
		prod *= primes[idx]
	print(idx)


print(*map(lambda y: sum(map(lambda x: x <= y, (2, 6, 30, 210, 2310, 30030, 510510, 9699690, 223092870, 6469693230, 200560490130, 7420738134810, 304250263527210, 13082761331670030, 614889782588491410))), (int(input()) for _ in range(int(input())))), sep='\n')


primeMult = []
s = 1
for i in range(2, 70):
	f = 0
	for j in range(2, int(i ** 0.5) + 1):
		if i % j == 0:
			f = 1
			break
	if f == 0:
		s *= i
		primeMult += [s]
t = int(input())
while t:
	n = int(input())
	for i in range(len(primeMult)):
		if primeMult[i] > n:
			print(i)
			break
	t -= 1


def prime(n):
	for d in range(2, int(n ** 0.5) + 1):
		if not n % d:
			return False
	return True
m = 2
n = 1
ndict = {1: 2}
for p in range(3, 100):
	if not prime(p):
		continue
	n += 1
	m *= p
	ndict[n] = m
	if m > 10 ** 18:
		break
n = int(input())
for i in range(n):
	q = int(input())
	for a in range(1, len(ndict) + 1):
		if q < ndict[a]:
			print(a - 1)
			break


primes = []
prod = 1
n = 2
while prod < 10 ** 19:
	if not any((n % p == 0 for p in primes)):
		primes.append(n)
		prod *= n
	n += 1
for _ in range(int(input())):
	p = 1
	i = 0
	n = int(input())
	while p * primes[i] <= n:
		p *= primes[i]
		i += 1
	print(i)


def dprimes(n):
	if n < 2:
		return 0
	if n < 6:
		return 1
	if n < 30:
		return 2
	if n < 210:
		return 3
	if n < 2310:
		return 4
	if n < 30030:
		return 5
	if n < 510510:
		return 6
	if n < 9699690:
		return 7
	if n < 223092870:
		return 8
	if n < 6469693230:
		return 9
	if n < 200560490130:
		return 10
	if n < 7420738134810:
		return 11
	if n < 304250263527210:
		return 12
	if n < 13082761331670030:
		return 13
	if n < 614889782588491410:
		return 14
	if n < 32589158477190044730:
		return 15
	return 16
out = []
T = int(input())
for t in range(T):
	out.append(dprimes(int(input())))
for o in out:
	print(o)


import math

def primes_less_than(n):
	sieve_me = [i for i in range(0, n)]
	prime = 2
	while True:
		if prime * prime > n:
			break
		for i in range(prime * prime, n, prime):
			sieve_me[i] = -1
		prime += 1
		while sieve_me[prime] == -1:
			prime += 1
		prime = sieve_me[prime]
	return [sieved for sieved in sieve_me if sieved not in [-1, 0, 1]]
q = int(input())
for i in range(q):
	n = int(input())
	primes = primes_less_than(100)
	primes_needed = 0
	primorial = 2
	while primorial <= n:
		primes_needed += 1
		primorial *= primes[primes_needed]
	print(primes_needed)


def prime_gen():
	primes = [2, 3]
	yield 2
	yield 3
	n = 3
	while True:
		n += 1
		composite = False
		for p in primes:
			if n % p == 0:
				composite = True
				break
			if p * p > n:
				break
		if not composite:
			primes += [n]
			yield n
for _ in range(int(input())):
	n = int(input())
	prod = 1
	count = 0
	for p in prime_gen():
		if p * prod > n:
			break
		prod *= p
		count += 1
	print(count)


import math

def is_prime(x):
	if x < 2:
		return False
	if x == 2:
		return True
	elif x == 3:
		return True
	else:
		if x % 2 == 0:
			return False
		if x % 3 == 0:
			return False
		max_divisor = int(math.sqrt(x)) + 1
		increment = 2
		divisor = 5
		while divisor <= max_divisor:
			if x % divisor == 0:
				return False
			divisor += increment
			increment = 6 - increment
		return True

def count_unique_primes_count_for_product_lesser_or_equal_to(n):
	product = 1
	count = 0
	for i in range(2, n + 1):
		if is_prime(i):
			if product * i <= n:
				product *= i
				count += 1
			else:
				break
	return count
q = int(input())
for _ in range(q):
	n = int(input())
	result = count_unique_primes_count_for_product_lesser_or_equal_to(n)
	print(result)


def genPrimes(lim=10 ** 6 + 1):
	sieve = [True] * lim
	for i in range(3, int(lim ** 0.5) + 1, 2):
		if sieve[i]:
			sieve[i * i::2 * i] = [False] * int((lim - i * i - 1) / (2 * i) + 1)
	return [2] + [i for i in range(3, lim, 2) if sieve[i]]
primes = genPrimes()
for _ in range(int(input())):
	n = int(input())
	prod = 1
	ind = 0
	for i in range(len(primes)):
		if prod > n:
			ind = i - 1
			break
		prod *= primes[i]
	print(ind)


q = int(input())
for _ in range(q):
	n = int(input())
	if n == 1:
		print(0)
	else:
		primearray = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59]
		prime = 0
		benchmark = 1
		while benchmark <= n:
			benchmark = benchmark * primearray[prime]
			prime += 1
		print(prime - 1)


import math

def is_prime(num):
	for j in range(2, int(math.sqrt(num) + 1)):
		if num % j == 0:
			return False
	return True
f = [2]
for i in range(3, 1000):
	if is_prime(i):
		f.append(i)
for i in range(int(input())):
	n = int(input())
	res = 1
	tot = 0
	for i in range(len(f)):
		if res * f[i] <= n:
			res *= f[i]
			tot += 1
		else:
			break
	print(tot)


def is_prime(n):
	if n == 2 or n == 3:
		return True
	if n < 2 or n % 2 == 0 or n % 3 == 0:
		return False
	(f, r) = (5, int(n ** 0.5))
	while f <= r:
		if n % f == 0:
			return False
		f += 2
	return True
for i in range(int(input())):
	n = int(input())
	(acc, index, count) = (1, 1, 0)
	while acc <= n:
		if is_prime(index):
			acc *= index
			if acc <= n:
				count += 1
		index += 1
	print(count)


T = int(input().strip())
for a0 in range(T):
	arr = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]
	n = int(input())
	(count, c) = (0, 1)
	for i in range(len(arr)):
		c = c * arr[i]
		count += 1
		if c > n:
			print(count - 1)
			break


q = int(input().strip())
primi = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53]
for i in range(q):
	n = int(input().strip())
	if n < 2:
		print(0)
	elif n == 2:
		print(1)
	else:
		numero = 2
		j = 1
		while numero <= n:
			numero *= primi[j]
			j += 1
		print(j - 1)


def prime_factors(n):
	factors = []
	d = 2
	while n > 1:
		while n % d == 0:
			factors.append(d)
			n /= d
		d = d + 1
		if d * d > n:
			if n > 1:
				factors.append(n)
			break
	return factors

def countFactor(n):
	c = 0
	no = 1
	primes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59]
	while no <= n:
		no = no * primes[c]
		c += 1
	return c - 1

def main():
	q = int(input())
	while q:
		q -= 1
		n = int(input())
		print(countFactor(n))
main()


a = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53]
for _ in range(int(input())):
	b = int(input())
	c = 1
	i = 0
	while c <= b:
		c *= a[i]
		i += 1
	print(i - 1)


MAX = 10 ** 4
SQRT_MAX = 10 ** 2

def sieve():
	prime = [True] * (MAX + 1)
	prime[0] = prime[1] = False
	for i in range(2, SQRT_MAX + 1, 1):
		for j in range(i * i, MAX + 1, i):
			prime[j] = False
	return [i for (i, prime) in enumerate(prime) if prime]
q = int(input())
primes = sieve()
for _ in range(q):
	n = int(input())
	product = 1
	i = 0
	while True:
		if product * primes[i] > n:
			break
		product *= primes[i]
		i += 1
	print(i)


lista = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59]
mult = [2]
for i in range(1, len(lista)):
	mult += [lista[i] * mult[i - 1]]
for i in range(int(input())):
	entrada = int(input())
	conta = 0
	for i in range(len(mult)):
		if mult[i] <= entrada:
			conta += 1
		else:
			break
	print(conta)


from math import sqrt
from bisect import bisect_left

def is_prime(n):
	if n < 2 or n % 2 == 0:
		return False
	for i in range(3, int(sqrt(n)) + 1, 2):
		if n % i == 0:
			return False
	return True

def next_prime():
	_i = 1
	yield [_i, 2]
	i = 3
	while True:
		if is_prime(i):
			_i += 1
			yield [_i, i]
		i += 2
l = [1]
lim = 10 ** 18
for (i, p) in next_prime():
	if l[i - 1] * p <= lim:
		l.append(l[i - 1] * p)
	else:
		break
q = int(input())
for _ in range(q):
	n = int(input())
	print(bisect_left(l, n + 1) - 1)


def is_prime(n):
	if n <= 1:
		return False
	for i in range(2, int(n ** 0.5) + 1):
		if n % i == 0:
			return False
	return True

def prime_prod_upto(n):
	prod = 1
	j = 1
	i = 0
	while prod <= n:
		if is_prime(j):
			prod = prod * j
			i += 1
		j += 1
	return i - 1
T = int(input().strip())
for t in range(T):
	n = int(input().strip())
	print(prime_prod_upto(n))


lista = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59]
mult = [2]
for i in range(1, len(lista)):
	mult += [lista[i] * mult[i - 1]]
for i in range(int(input())):
	entrada = int(input())
	conta = 0
	for i in range(len(mult)):
		if mult[i] <= entrada:
			conta += 1
		else:
			break
	print(conta)


a = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59]
t = int(input())
for j in range(t):
	n = int(input())
	mult = 1
	for i in range(len(a)):
		mult = mult * a[i]
		if mult <= n:
			i += 1
		else:
			r = i
			break
	if n == 1:
		r = 0
	print(r)


import itertools
import operator
from bisect import bisect_right
q = int(input())
l = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 51, 53, 59]
lcum = list(itertools.accumulate(l, operator.mul))
for _ in range(q):
	n = int(input())
	print(bisect_right(lcum, n))


q = int(input())
primes = [1 for x in range(100)]
primes[0] = primes[1] = 0
for number in range(2, 100):
	i = number
	while i < 100:
		if number == i:
			i += number
			continue
		if primes[i] == 1:
			primes[i] = 0
		i += number
arr = []
num = 1
for i in range(2, 100):
	if primes[i] == 1 and num < 10 ** 18:
		num *= i
		arr.append(i)
for x in range(q):
	n = int(input())
	num = 1
	count = 0
	for x in arr:
		num *= x
		if num <= n:
			count += 1
	print(count)


import functools

def sieve_of_eratosthenes(max_value):
	if max_value < 3:
		return []
	elif max_value == 3:
		return [2]
	sieve = list(range(3, max_value, 2))
	cur_pos = 0
	cur_prime = sieve[cur_pos]
	while cur_prime ** 2 < max_value:
		start_pos = cur_pos + cur_prime
		zeros_len = (max_value - cur_prime - 1) // cur_prime // 2
		sieve[start_pos::cur_prime] = [0] * zeros_len
		while True:
			cur_pos += 1
			cur_prime = sieve[cur_pos]
			if cur_prime:
				break
	sieve.insert(0, 2)
	return list(filter(None, sieve))
known_primes = sieve_of_eratosthenes(54)
T = int(input().strip())
for i in range(T):
	n = int(input().strip())
	value = 1
	for (count, prime) in enumerate(known_primes):
		value *= prime
		if value > n:
			break
	print(count)


for i in range(int(input())):
	x = int(input().strip())
	(i, sm, lst) = (2, 2, [2])
	while sm <= x:
		for j in lst:
			if i % j == 0:
				break
		else:
			if sm * i > x:
				break
			sm *= i
			lst.append(i)
		i += 1
	print(len(lst) if x != 1 else 0)


def GCD(a, b):
	(a, b) = (max(a, b), min(a, b))
	while b != 0:
		(a, b) = (b, a % b)
	return a
l = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53]
k = []
t = 1
for i in range(len(l)):
	t *= l[i]
	k.append([i + 1, t])
for t in range(int(input())):
	x = int(input())
	for i in k:
		if i[1] > x:
			print(i[0] - 1)
			break


q = int(input().strip())
primes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 7173, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257]
for i in range(q):
	n = int(input().strip())
	count = 0
	if n == 1:
		print(0)
	else:
		res = 1
		for j in range(len(primes)):
			res2 = res * primes[j]
			if res2 <= n:
				res = res2
				count = count + 1
			else:
				break
		print(count)


def prime(n):
	a = [True for i in range(n + 1)]
	r = []
	(a[0], a[1]) = (False, False)
	for i in range(2, n + 1):
		if a[i]:
			r.append(i)
			j = 2
			while i * j <= n:
				a[i * j] = False
				j += 1
	return r

def product(a):
	r = 1
	if len(a) == 0:
		return 0
	for i in range(len(a)):
		r *= a[i]
	return r
p = prime(53)
q = int(input())
for q_i in range(q):
	n = int(input())
	if n == 1:
		print(0)
	else:
		r = 1
		i = 0
		while i < len(p) and r * p[i] <= n:
			r *= p[i]
			i += 1
		print(i)


primes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]
primeFactorials = [1]
for prime in primes:
	primeFactorials.append(primeFactorials[-1] * prime)
n = int(input())
for i in range(n):
	val = int(input())
	for a in range(len(primeFactorials)):
		if primeFactorials[a] <= val and primeFactorials[a + 1] > val:
			print(a)
			break


import math
primes_count = [2, 6, 30, 210, 2310, 30030, 510510, 9699690, 223092870, 6469693230, 200560490130, 7420738134810, 304250263527210, 13082761331670030, 614889782588491410, 32589158477190044730, 1922760350154212639070]

def getMaximumNumberofUniquePrimeFactors(n, start, end):
	if primes_count[start] == n:
		return start + 1
	if primes_count[end] == n:
		return end + 1
	if n > primes_count[start] and n < primes_count[end]:
		if end - start == 1:
			return start + 1
		left = getMaximumNumberofUniquePrimeFactors(n, start, math.ceil((start + end) / 2))
		if left:
			return left
		else:
			return getMaximumNumberofUniquePrimeFactors(n, math.ceil((start + end) / 2), end)
	else:
		return 0
Q = int(input())
while Q > 0:
	n = int(input())
	if n == 1:
		print('0')
	else:
		print(getMaximumNumberofUniquePrimeFactors(n, 0, len(primes_count) - 1))
	Q -= 1


primes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53]

def max_prime_factors(n):
	x = 1
	i = 0
	while i < 16 and x <= n:
		x = x * primes[i]
		i = i + 1
	return i - 1
for _ in range(int(input())):
	print(max_prime_factors(int(input())))


primes = [2, 3]
prods = [2, 6]

def is_prime(n):
	for p in primes:
		if n % p == 0:
			return False
	return True

def find_prime():
	n = primes[-1] + 2
	while not is_prime(n):
		n += 2
	primes.append(n)

def f(n):
	while n > prods[-1]:
		find_prime()
		prods.append(prods[-1] * primes[-1])
	i = len(prods)
	while i > 0 and prods[i - 1] > n:
		i -= 1
	return i
T = int(input())
for t in range(T):
	print(f(int(input())))


import sys
from functools import reduce
sys.stdin.readline()
primes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53]
for line in sys.stdin:
	rangeMax = int(line)
	total = 1
	if rangeMax == 1:
		print(0)
	else:
		for i in range(0, len(primes)):
			total *= primes[i]
			if total > rangeMax:
				print(i)
				break


import math

def prime(n):
	for i in range(2, int(math.sqrt(n)) + 1):
		if n % i == 0:
			return False
	return True
for _ in range(int(input())):
	v = int(input())
	i = 2
	p = 1
	c = 0
	while p < v:
		if prime(i):
			p *= i
			c += 1
		i += 1
	if v <= 2:
		print(c)
	elif v == p:
		print(c)
	else:
		print(c - 1)


from math import sqrt
primes = [2, 3]
mults = [2, 6]

def is_prime(n: int) -> bool:
	if n < 2:
		return False
	if n in primes:
		return True
	o = int(1 + sqrt(n))
	for x in primes:
		if x > o:
			primes.append(n)
			return True
		if n % x == 0:
			return False
	for v in range(primes[-1] + 2, o):
		if n % v == 0:
			return False
	primes.append(n)
	return True
q = int(input())
for _ in range(q):
	n = int(input())
	pos = None
	for (i, v) in enumerate(mults):
		if v > n:
			pos = i
			break
	if pos is None:
		last_prime = primes[-1]
		v = mults[-1]
		i = last_prime
		while v < n:
			i += 2
			while not is_prime(i):
				i += 2
			v *= i
			mults.append(v)
		if mults[-1] == n:
			pos = len(mults)
		elif mults[-1] > n:
			pos = len(mults) - 1
	print(pos)


import itertools
from itertools import accumulate
import operator
q = int(input())
primes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53]
tulot = list(accumulate(primes, operator.mul))
while q > 0:
	n = int(input())
	if n < 2:
		print(0)
	if 2 <= n <= 3:
		print(1)
	if n > 3:
		count = 0
		for tulo in tulot:
			if tulo <= n:
				count += 1
		print(count)
	q -= 1


primes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277]
minPrimeMultipleOfIPrimes = []
last = 1
for i in range(30):
	last = last * primes[i]
	minPrimeMultipleOfIPrimes.append(last)
for _ in range(int(input())):
	x = int(input())
	for i in range(30):
		if minPrimeMultipleOfIPrimes[i] > x:
			print(i)
			break


def isprime(n):
	if n <= 3:
		if n >= 2:
			return True
		return False
	if (n % 2 == 0) | (n % 3 == 0):
		return False
	for i in range(5, int(n ** 0.5) + 1, 6):
		if (n % i == 0) | (n % (i + 2) == 0):
			return False
	return True
s = 1
S = [1]
n = 2
while s < 10 ** 18:
	if isprime(n):
		s *= n
		S.append(s)
	n += 1
N = int(input())
for n0 in range(N):
	T = int(input())
	i = 0
	while S[i] <= T:
		i += 1
	print(i - 1)