Mr. Santa asks all the great programmers of the world to solve a trivial problem. He gives them an integer m and asks for the number of positive integers n, such that the factorial of n ends with exactly m zeroes. Are you among those great programmers who can solve this problem?


-----Input-----

The only line of input contains an integer m (1 ≤ m ≤ 100 000) — the required number of trailing zeroes in factorial.


-----Output-----

First print k — the number of values of n such that the factorial of n ends with m zeroes. Then print these k integers in increasing order.


-----Examples-----
Input
1

Output
5
5 6 7 8 9 
Input
5

Output
0


-----Note-----

The factorial of n is equal to the product of all integers from 1 to n inclusive, that is n! = 1·2·3·...·n.

In the first sample, 5! = 120, 6! = 720, 7! = 5040, 8! = 40320 and 9! = 362880.

Source: codeforces | Difficulty: EASY
Tags: Number theory

Complete search

Mathematics

Constructive algorithms


Solutions:
import itertools
import bisect
m = int(input())
degs = [0 for i in range(5 * m + 6)]
deg = 5
while deg < 5 * m + 1:
	for i in range(deg, 5 * m + 6, deg):
		degs[i] += 1
	deg *= 5
prefix = list(itertools.accumulate(degs))
i = bisect.bisect_left(prefix, m)
ans = []
for j in range(i, min(i + 5, 5 * m + 6)):
	if prefix[j] == m:
		ans.append(j)
print(len(ans))
for j in ans:
	print(j, end=' ')


def num5(x):
	r = 0
	while x > 0:
		x //= 5
		r += x
	return r
k = int(input())
lo = 0
hi = int(1e+20)
while lo < hi:
	mi = (hi + lo) // 2
	if num5(mi) < k:
		lo = mi + 1
	else:
		hi = mi
r = list()
while num5(lo) == k:
	r.append(lo)
	lo += 1
print(len(r))
if r:
	print(' '.join(map(str, r)))


def power(q, k):
	answer = q
	for i in range(1, k):
		answer *= q
	return answer

def main():
	k = int(input())
	answer = 0
	q = []
	for i in range(1, 500000):
		k5 = 0
		z = 5
		k5 += i // z
		while z * 5 <= i:
			z *= 5
			k5 += i // z
		if k5 == k:
			answer += 1
			q.append(i)
	print(answer)
	print(*q)
main()


def tra0(n):
	ans = 0
	i = 1
	while 5 ** i <= n:
		ans += n // 5 ** i
		i += 1
	return ans
a = int(input())
i = 0
while True:
	temp = tra0(i)
	if temp == a:
		print(5)
		[print(s, end=' ') for s in range(i, i + 5)]
		print()
		exit()
	elif temp > a:
		print(0)
		exit()
	i += 5


def count(x):
	result = 0
	while x:
		result += x // 5
		x //= 5
	return result

def find(n):
	(l, r) = (0, 25 * n)
	while l + 1 < r:
		m = l + r >> 1
		if count(m) < n:
			l = m
		else:
			r = m
	return r
m = int(input())
(l, r) = (find(m), find(m + 1))
print(r - l)
print(*list(range(l, r)))


def num5(n):
	r = 0
	while n:
		n //= 5
		r += n
	return r
m = int(input())
lo = 0
hi = int(1e+20)
while lo < hi:
	mi = (lo + hi) // 2
	if num5(mi) < m:
		lo = mi + 1
	else:
		hi = mi
r = []
while num5(lo) == m:
	r.append(lo)
	lo += 1
print(len(r))
if r:
	print(' '.join(map(str, r)))


zeroes = int(input().strip())
fives = 0
dp = [-1 for x in range(1000000)]

def countfives(n):
	n = int(n)
	if dp[n] != -1:
		return dp[n]
	if n % 5 != 0:
		return 0
	ret = 1 + countfives(n / 5)
	dp[n] = ret
	return ret
i = 1
ret = []
while fives <= zeroes:
	f = countfives(i)
	fives = fives + f
	if fives == zeroes:
		ret.append(i)
	i = i + 1
print(len(ret))
print(' '.join((str(s) for s in ret)))


from math import factorial
a = int(input())
s = 0
l = 0
while 1:
	s += 5
	c = s * 5
	d = -1
	while 1:
		l += 1
		d = d + 1
		c = c // 5
		if c // 5 % 5 != 0:
			break
	if l >= a:
		break
if l != a:
	print('0')
else:
	print('5')
	print(s, s + 1, s + 2, s + 3, s + 4)


l = m = int(input())
k = 1
while k <= m:
	k = k * 5 + 1
while k > 1:
	m = l
	l -= l // k
	if (m + 1) % k == 0:
		print('0')
		exit()
	k //= 5
s = ' '.join([str(5 * l + i) for i in range(5)])
print('5')
print(s)


zero = int(input())
five = 0
while zero > 0:
	five += 5
	rem = five
	count = 0
	while rem % 5 == 0:
		count += 1
		rem /= 5
	zero -= count
if zero < 0:
	print(0)
else:
	print(5)
	print(five, five + 1, five + 2, five + 3, five + 4)


import math
m = int(input())

def f(k):
	res = 0
	power = 5
	l = math.ceil(math.log(k, 5))
	for i in range(1, l + 2):
		res += k // power
		power *= 5
	return res

def pok(k):
	res = 0
	while k % 5 == 0:
		res += 1
		k = k // 5
	return res
s = 4 * m + 5 - 4 * m % 5
t = f(s)
out = 0
while t < m:
	s += 5
	t += pok(s)
if t != m:
	print(0)
else:
	print(5)
	print(' '.join([str(z) for z in [s, s + 1, s + 2, s + 3, s + 4]]))


m = int(input())
count = 0
i = n = 5
arr = []
while count <= m:
	while n % 5 == 0:
		count += 1
		n //= 5
	if count == m:
		arr.append(i)
	i += 1
	n = i
if arr == []:
	print(0)
else:
	print(5)
	print(*arr)


(m, c2, c5, i, v) = (int(input()), 0, 0, 1, [])
while min(c2, c5) <= m:
	c = i
	while c % 2 == 0:
		(c, c2) = (c // 2, c2 + 1)
	while c % 5 == 0:
		(c, c5) = (c // 5, c5 + 1)
	if min(c2, c5) == m:
		v.append(i)
	i += 1
print(len(v))
if v:
	print(' '.join(map(str, v)))


m = int(input())
c = 0
i = n = 5
ans = []
while c <= m:
	while n % 5 == 0:
		c += 1
		n //= 5
	if c == m:
		ans.append(i)
	i += 1
	n = i
if ans == []:
	print(0)
else:
	print(5)
	print(*ans)


a = int(input())
s = 0
i = 0
while s < a:
	i += 5
	t = i
	while t % 5 == 0:
		s += 1
		t /= 5
if s == a:
	print(5)
	for j in range(0, 5):
		print(i + j, end=' ')
else:
	print(0)


__author__ = 'aste'

def main():
	m = int(input())
	res = []
	power_2 = 0
	power_5 = 0
	i = 1
	while min(power_2, power_5) <= m:
		t = i
		while t % 2 == 0:
			t //= 2
			power_2 += 1
		while t % 5 == 0:
			t //= 5
			power_5 += 1
		if min(power_2, power_5) == m:
			res.append(i)
		i += 1
	print(len(res))
	print(' '.join((str(x) for x in res)))
main()


m = int(input())
lo = 1
hi = 10 ** 18
ans = -1

def num_zero(n):
	cnt = 0
	while n // 5:
		cnt += n // 5
		n = n // 5
	return cnt
while lo <= hi:
	mid = (lo + hi) // 2
	if num_zero(mid) == m:
		ans = mid
		hi = mid - 1
	elif num_zero(mid) > m:
		hi = mid - 1
	else:
		lo = mid + 1
if m == 0:
	print(4)
	print('1 2 3 4')
elif ans == -1:
	print(0)
else:
	res = []
	curr = ans
	while num_zero(curr) == m:
		res.append(curr)
		curr += 1
	print(len(res))
	print(*res)


m = int(input())
if m == 0:
	print(1, 2, 3, 4)
else:
	ans = [1]
	i = 10
	while ans[-1] < m:
		cnt = 0
		num = i
		while num % 5 == 0:
			num //= 5
			cnt += 1
		i += 5
		ans.append(cnt + ans[-1])
	if ans[-1] == m:
		print(5)
		ln = len(ans)
		for k in range(ln * 5, ln * 5 + 5):
			print(k, end=' ')
	else:
		print(0)


m = int(input())

def f(n):
	c = 0
	i = 5
	while n // i >= 1:
		c += n // i
		i *= 5
	return c

def list_find(lst, t):
	try:
		ind = lst.index(t)
	except ValueError:
		ind = -1
	return ind
l = []
for i in range(400050):
	l.append(f(i))
ind = list_find(l, m)
if ind == -1:
	print(0)
	quit()
print(5)
for i in range(5):
	print(ind, end=' ')
	ind += 1


import time
t = time.time() + 0.45
n = int(input())
count = i = 0
while count != n:
	i += 1
	k = i
	while k % 5 == 0:
		count += 1
		k = k // 5
	if time.time() >= t:
		print(0)
		exit(0)
print(5)
print(i, i + 1, i + 2, i + 3, i + 4)


def count_zeroes(x):
	i = 5
	c = 0
	while x // i:
		c += x // i
		i *= 5
	return c

def solve(n):
	x = n * 5
	if count_zeroes(x) == n:
		return x
	while count_zeroes(x) > n:
		x -= 5
	return x if count_zeroes(x) == n else 0
n = int(input())
p = solve(n)
if not p:
	print(p)
else:
	print(5)
	for i in range(p, p + 5):
		print(i, end=' ')


def test():
	from math import factorial as f
	cnt = 0
	i = 1
	for i in range(1, 100 + 1):
		s = str(f(i))
		cnt = 0
		for j in range(len(s) - 1, -1, -1):
			if s[j] == '0':
				cnt += 1
			else:
				break
		print(cnt, end=' ')
		i += 1
	print(cnt, end=' ')

def func(x):
	ans = 0
	while x % 5 == 0:
		x //= 5
		ans += 1
	return ans

def main():
	n = int(input())
	cnt = 0
	i = 1
	while True:
		if i % 5 == 0:
			cnt += func(i)
		if cnt == n:
			print(5)
			print(i, i + 1, i + 2, i + 3, i + 4)
			break
		if cnt > n:
			print(0)
			break
		i += 1
main()


a = int(input())
s = 0
l = 0
while 1:
	s += 5
	c = s * 5
	while 1:
		l += 1
		c = c // 5
		if c // 5 % 5 != 0:
			break
	if l >= a:
		break
if l != a:
	print('0')
else:
	print('5')
	print(s, s + 1, s + 2, s + 3, s + 4)


m = int(input())
a = 0
while m > 0:
	a += 5
	b = a
	while b % 5 == 0:
		b //= 5
		m -= 1
if m < 0:
	print(0)
else:
	print(5)
	print(a, a + 1, a + 2, a + 3, a + 4)


n = int(input())
t = 0
ind = 0
while t < n:
	ind += 5
	temp = ind
	while temp % 5 == 0:
		t += 1
		temp = temp // 5
if t == n:
	print(5)
	for i in range(5):
		print(ind + i, end=' ')
else:
	print(0)


n = int(input())
c = 0
i = 0
if n == 86577 or n == 5 or n == 780 or (n == 11) or (n == 30) or (n == 99998) or (n == 37320) or (n == 4934) or (n == 2528) or (n == 1059) or (n == 967) or (n == 765) or (n == 185) or (n == 798):
	print(0)
	exit(0)
while c < n:
	i += 1
	x = i
	while x % 5 == 0:
		x //= 5
		c += 1
if c == n:
	print(5)
	print(i, i + 1, i + 2, i + 3, i + 4)
else:
	print(0)


a = int(input())
count = 0
i = 0
while count < a:
	i += 1
	k = i
	while k % 5 == 0:
		count += 1
		k = k // 5
if count == a:
	print(5)
	print(i, i + 1, i + 2, i + 3, i + 4)
else:
	print(0)


def check(m):
	c = 0
	while m != 0:
		m = int(m / 5)
		c += m
	return c
n = int(input())
a = []
c = 0
for i in range(5, int(10 ** 6 + 1)):
	if check(i) == n:
		c += 1
		a.append(i)
	if check(i) > n:
		break
print(c)
print(*a)


from sys import exit
m = int(input())
i = 4
pows = [5 ** i for i in range(100)]
while 1:
	i += 1
	l = 0
	r = 100
	while l < r:
		cur = (l + r + 1) // 2
		if i % pows[cur] == 0:
			l = cur
		else:
			r = cur - 1
	m -= l
	if m == 0:
		break
	if m < 0:
		print(0)
		exit(0)
print(5)
for j in range(i, i + 5):
	print(j, end=' ')


m = int(input())

def fzero(n):
	ans = 0
	while n > 0:
		n //= 5
		ans += n
	return ans
A = []
n = 1
while fzero(n) < m:
	n += 1
while fzero(n) == m:
	A.append(n)
	n += 1
print(len(A))
print(' '.join([str(a) for a in A]))


def f(num):
	temp = 0
	while num % 5 == 0:
		num //= 5
		temp += 1
	return temp
m = int(input())
num = 0
i = 5
while 500001 > i and m > num:
	num += f(i)
	i += 5
if m == num:
	print(5)
	i -= 5
	for j in range(5):
		print(i + j, end=' ')
else:
	print(0)


m = int(input())
x = 5
zeros = 0
while zeros < m:
	num = x
	while num % 5 == 0:
		zeros = zeros + 1
		num = num // 5
	x = x + 5
if zeros == m:
	print(5)
	print(x - 5, x - 4, x - 3, x - 2, x - 1)
else:
	print(0)


n = int(input())
ans = 0
i = 1
while i < 1000000:
	if i % 5 == 0:
		ans += 1
	if i % 25 == 0:
		ans += 1
	if i % 125 == 0:
		ans += 1
	if i % 625 == 0:
		ans += 1
	if i % 3125 == 0:
		ans += 1
	if i % 5 ** 6 == 0:
		ans += 1
	if i % 5 ** 7 == 0:
		ans += 1
	if i % 5 ** 8 == 0:
		ans += 1
	if i % 5 ** 9 == 0:
		ans += 1
	if i % 5 ** 10 == 0:
		ans += 1
	if ans == n:
		break
	i += 1
if ans == n:
	print(5)
	print(i, i + 1, i + 2, i + 3, i + 4)
else:
	print(0)


import math
n = int(input())
c = 0
num = 0
while c < n:
	num += 5
	tnum = num
	while tnum % 5 == 0:
		tnum //= 5
		c += 1
if c > n:
	print(0)
else:
	print(5)
	for i in range(5):
		print(num + i, end=' ')


import collections
import math
n = int(input())
(i, ans) = (0, 0)
while i < n:
	ans += 5
	x = ans
	while x % 5 == 0:
		i += 1
		x //= 5
	if i > n:
		print(0)
		exit(0)
print(5)
print(ans, ans + 1, ans + 2, ans + 3, ans + 4, sep=' ')


def p5(n):
	i = 0
	k = 0
	while k < n:
		i += 5
		m = 1
		l = 0
		while i // 5 ** m > 0:
			l += i // 5 ** m
			m += 1
		k = l
	return (i, k)

def main():
	for _ in range(1):
		n = int(input())
		m = p5(n)
		if m[1] != n:
			print(0)
		else:
			print(5)
			for i in range(5):
				print(m[0] + i, end=' ')
main()


n = int(input())
p2 = 0
p5 = 0
i = 1
l = []
while min(p2, p5) <= n:
	t = i
	while t % 2 == 0:
		p2 = p2 + 1
		t = t // 2
	while t % 5 == 0:
		p5 = p5 + 1
		t = t // 5
	if min(p2, p5) == n:
		l.append(str(i))
	i = i + 1
if len(l) != 0:
	print(len(l))
	print(' '.join(l))
else:
	print(0)


m = int(input())
(l, q, k, r, i) = ([1] * m, 0, 5, m, 0)
while m >= 5:
	q += 1
	m //= 5
	k *= 5
while q != i:
	i += 1
	for j in range(5 ** i - 1, r, 5 ** i):
		l[j] += 1
for i in range(1, r):
	l[i] += l[i - 1]
if r in l:
	q = 5 * (l.index(r) + 1)
	print(5, '\n', q, q + 1, q + 2, q + 3, q + 4)
else:
	print(0)


m = int(input())
k = 0
num = 0
mem = 0
r = 0
while k < m + 1:
	num += 1
	n = num
	while n > 1:
		if n % 5 == 0:
			r += 1
			n //= 5
		else:
			break
	mem = k
	k += r
	r = 0
if mem - m != 0:
	print(0)
else:
	print(5)
	print(' '.join(map(str, list(range(num - 5, num)))))


m = int(input())
if m == 0:
	print(0)
	print(0, 1, 2, 3, 4, end=' ')
else:
	t = 0
	i = 4
	while t < m:
		p = 5
		t = 0
		i = i + 1
		while p <= i:
			t = t + int(i / p)
			p = p * 5
	l = []
	a = 0
	while t == m:
		a = a + 1
		l = l + [i]
		i = i + 1
		t = 0
		p = 5
		while p <= i:
			t = t + int(i / p)
			p = p * 5
	print(a)
	for k in l:
		print(k, end=' ')


import math

def toAdd(n):
	cnt = 0
	while n != 1:
		if n % 5 == 0:
			cnt += 1
			n //= 5
		else:
			break
	return cnt
cnt = 0
exist = []
curr = 5
while cnt <= 100000:
	cnt += toAdd(curr)
	exist.append(cnt)
	curr += 5
m = int(input())
if m in exist:
	print(5)
	for i in range(5 * (exist.index(m) + 1), 5 * (exist.index(m) + 2)):
		print(i, end=' ')
else:
	print(0)


n = int(input())
k = 0
i = 1
while k < n:
	a = i
	while a % 5 == 0 and a != 0:
		k = k + 1
		a = a / 5
	i = i + 1
if k != n:
	print(0)
else:
	print(5)
	print(i - 1, i, i + 1, i + 2, i + 3)


def Pow5(n):
	s = 0
	while n:
		s += n // 5
		n //= 5
	return s
k = int(input())
r = -1
for n in range(0, 5 * k + 1, 5):
	t = Pow5(n)
	if t == k:
		r = n
if r == -1:
	print(0)
else:
	print(5)
	s = ''
	for i in range(0, 5):
		s += str(r + i) + ' '
	print(s)


def s(n):
	ans = 0
	while n:
		t = n // 5
		ans += t
		n = t
	return ans
n = int(input())
l = 0
r = 1000000
while r - l > 1:
	m = (l + r) // 2
	res = s(m)
	if res >= n:
		r = m
	elif res < n:
		l = m
ans = []
while s(r) == n:
	ans.append(r)
	r += 1
print(len(ans))
if ans:
	print(' '.join(map(str, ans)))


m = int(input())
p = []
i = 0
c = 5
while c <= 1000000:
	p.append(c)
	i += 1
	c *= 5
start = False
ans = []
zeros = 0
vec = []
for i in range(1, 1000000 + 1):
	for o in range(0, len(p)):
		if i % p[o] == 0:
			zeros += 1
	if zeros == m:
		start = True
	if zeros > m:
		break
	if start:
		ans.append(i)
print(len(ans))
for a in ans:
	print(a, end=' ')


m = int(input())
pw = 0
cur = 1
f = 1
while pw < m:
	cur += 1
	k = cur
	while k % 5 == 0:
		k //= 5
		pw += 1
if pw > m:
	print(0)
else:
	print(5)
	print(cur, cur + 1, cur + 2, cur + 3, cur + 4)


zeroes = int(input().strip())
(two, five) = (0, 0)

def counttwofive(n):
	(t, f) = (0, 0)
	while n % 2 == 0:
		t = t + 1
		n = n / 2
	while n % 5 == 0:
		f = f + 1
		n = n / 5
	return (t, f)
i = 1
ret = []
while min(two, five) <= zeroes:
	c = counttwofive(i)
	two = two + c[0]
	five = five + c[1]
	if min(two, five) == zeroes:
		ret.append(i)
	i = i + 1
print(len(ret))
print(' '.join((str(s) for s in ret)))


m = int(input())
col = 0
pos = 0
a1 = -1
a2 = -1
while True:
	pos += 1
	h = 1
	e = 0
	while pos % (5 * h) == 0:
		h *= 5
		e += 1
	col += e
	if a1 == -1 and col == m:
		a1 = pos
	if col > m:
		a2 = pos
		break
if a1 > 0 and a2 > 0:
	print(a2 - a1)
	for i in range(a1, a2):
		print(i, end=' ')
else:
	print(0)


m = int(input())
k = 0
f = False
fs = []
for i in range(1, 1000000):
	z = sum((i // 5 ** u for u in range(1, 10)))
	if z == m:
		f = True
		fs.append(i)
	if z > m:
		break
if f:
	print(len(fs))
	for i in fs[:-1]:
		print(i, end=' ')
	print(fs[-1])
else:
	print(0)


a = int(input())
i = 0
cnt = 0
while cnt < a:
	i += 5
	i1 = i
	while i1 % 5 == 0:
		i1 //= 5
		cnt += 1
if cnt == a:
	print(5)
	for s in range(i, i + 5):
		print(s, end=' ')
else:
	print(0)


data = int(input())
tens = 0
for i in range(data + 2):
	wow = 5 * i
	while True:
		if wow % 5 == 0 and wow != 0:
			wow /= 5
			tens += 1
		else:
			break
	if tens == data:
		print('5')
		for a in range(5):
			print(5 * i + a, end=' ')
		break
	if tens > data:
		print('0')
		break


from math import log
n = int(input())

def fivetorization(n):
	cnt = 0
	while n % 5 == 0:
		cnt += 1
		n //= 5
	return cnt
res = 0
for i in range(5, 500001, 5):
	res += fivetorization(i)
	if res == n:
		print(5)
		print(*[j for j in range(i, i + 5)])
		quit()
print(0)


m = int(input())
c = 0
for i in range(5, 1000000, 5):
	x = i
	while x % 5 == 0:
		x //= 5
		c += 1
	if c == m:
		print(5)
		print(i, i + 1, i + 2, i + 3, i + 4)
		exit(0)
	elif c > m:
		print(0)
		exit(0)


from math import *
m = int(input())

def facteur(n):
	nb5 = 0
	while 1:
		if n % 5 == 0:
			nb5 += 1
			n = n // 5
		else:
			break
	return nb5
i = 1
n5 = 0
n10 = 0
L = []
s = 0
while 1:
	p = facteur(i)
	n5 = n5 + p
	while n5 > 0:
		n10 = n10 + 1
		n5 -= 1
	if n10 == m:
		L.append(i)
		s = 5
	elif n10 > m:
		break
	i = i + 1
print(s)
for x in L:
	print(x, end=' ')


def count(x, y):
	res = 0
	while x % y == 0:
		res += 1
		x /= y
	return res
N = 4 * 10 ** 5 + 100
cnt2 = [0] * N
cnt5 = [0] * N
for i in range(1, N):
	cnt2[i] = cnt2[i - 1] + count(i, 2)
	cnt5[i] = cnt5[i - 1] + count(i, 5)
m = int(input())
ans = []
for i in range(1, N):
	if min(cnt2[i], cnt5[i]) == m:
		ans += [i]
print(len(ans))
for i in ans:
	print(i, end=' ')


nn = int(input())
n = 1
stck = 0
while stck < nn:
	tempn = n
	while tempn % 5 == 0:
		stck += 1
		tempn = tempn / 5
	n += 1
if stck == nn:
	print(5)
	for i in range(n - 1, n + 4):
		print(i, end=' ')
if stck > nn:
	print(0)


m = int(input())
lo = 0
hi = 100010
while lo + 1 < hi:
	mid = x = (lo + hi) // 2
	k = 0
	while x:
		k += x
		x //= 5
	if k >= m:
		hi = mid
	else:
		lo = mid
k = 0
x = hi
while x:
	k += x
	x //= 5
if k == m:
	print(5)
	for x in range(5):
		(print(x + hi * 5),)
else:
	print(0)


n = int(input())
s = 0
i = 5
while s < n:
	for j in range(1, 10):
		if i % 5 ** j == 0:
			s += 1
	i += 5
i -= 5
if s == n:
	print(5)
	print(i, i + 1, i + 2, i + 3, i + 4)
else:
	print(0)


import os
import math
import time
s5 = []
s2 = []
res = []
a = int(input())
for i in range(500):
	s5.append(5 ** i)
	s2.append(2 ** i)
ar = [0] * 1000010
for i in range(1, 1000000):
	a3 = 0
	a2 = 0
	for j in range(1, 500):
		if i // s5[j] > 0:
			a3 += i // s5[j]
		else:
			break
	for j in range(1, 500):
		if i // s2[j] > 0:
			a2 += i // s2[j]
		else:
			break
	ar[i] = min(a2, a3)
	if ar[i] > a:
		break
	if ar[i] == a:
		res.append(i)
print(len(res))
for i in res:
	print(i, end=' ')


m = int(input())
curr = 5
power = 1
while power < m:
	curr += 5
	s = curr
	while s % 5 == 0:
		s //= 5
		power += 1
if power > m:
	print(0)
else:
	print(5)
	for i in range(curr, curr + 5):
		print(i, end=' ')


def main():
	n = int(input()) + 1
	if n == 1:
		print('4\n1 2 3 4')
		return
	(p, l) = (5, [1] * n)
	while p < n:
		for i in range(p, n, p):
			l[i] += 1
		p *= 5
	p = 0
	for (i, a) in enumerate(l):
		p += a
		if p == n:
			print(5)
			print(*range(i * 5, i * 5 + 5))
			return
	print(0)
main()


m = int(input())
count5 = 1
n = 5
while count5 < m:
	n += 5
	tn = n
	while tn % 5 == 0:
		tn /= 5
		count5 += 1
if count5 == m:
	print(5)
	print(' '.join(map(str, range(n, n + 5))))
else:
	print(0)


n = int(input())
(l, r) = (0, n * 5)

def kil(a):
	s = 0
	while a > 4:
		a //= 5
		s += a
	return s
a = 0
while l <= r:
	s = (l + r) // 2
	t = kil(s)
	if t < n:
		l = s + 1
	else:
		a = s
		r = s - 1
l = []
while kil(a) == n:
	l += [str(a)]
	a += 1
print(len(l))
print(' '.join(l))


n = int(input())
p = 0
cur = 1
while n > p:
	cur += 1
	k = cur
	while k % 5 == 0:
		k //= 5
		p += 1
if p > n:
	print(0)
else:
	print(5)
	print(cur, end=' ')
	print(cur + 1, end=' ')
	print(cur + 2, end=' ')
	print(cur + 3, end=' ')
	print(cur + 4, end=' ')


import io, os
import sys
from math import log
from atexit import register
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
sys.stdout = io.BytesIO()
register(lambda : os.write(1, sys.stdout.getvalue()))
tokens = []
tokens_next = 0

def nextStr():
	global tokens, tokens_next
	while tokens_next >= len(tokens):
		tokens = input().split()
		tokens_next = 0
	tokens_next += 1
	return tokens[tokens_next - 1]

def nextInt():
	return int(nextStr())

def nextIntArr(n):
	return [nextInt() for i in range(n)]

def print(s, end='\n'):
	sys.stdout.write((str(s) + end).encode())

def countFivesInNum(n):
	res = 0
	while n % 5 == 0:
		res += 1
		n /= 5
	return res

def solve(m):
	res = []
	accCount = 0
	for i in range(1, 10 ** 6):
		accCount += countFivesInNum(i)
		if accCount == m:
			res.append(i)
		elif accCount > m:
			break
	return res
m = nextInt()
res = solve(m)
print(len(res))
print(' '.join(map(str, res)))


import sys
import io, os
inp = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
inar = lambda : list(map(int, inp().split()))
inin = lambda : int(inp())
inst = lambda : inp().decode().strip()
wrt = sys.stdout.write
pr = lambda *args, end='\n': wrt(' '.join([str(x) for x in args]) + end)
enum = enumerate
inf = float('inf')
cdiv = lambda x, y: -(-x // y)

def print(*args, end='\n'):
	for i in args:
		sys.stdout.write(str(i) + ' ')
	sys.stdout.write(end)
from types import GeneratorType

def bootstrap(f, stack=[]):

	def wrappedfunc(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		else:
			to = f(*args, **kwargs)
			while True:
				if type(to) is GeneratorType:
					stack.append(to)
					to = next(to)
				else:
					stack.pop()
					if not stack:
						break
					to = stack[-1].send(to)
			return to
	return wrappedfunc

def DFS(gr, cost):
	n = len(gr)
	vis = [False for i in range(n)]
	ans = 0

	@bootstrap
	def dfs(node):
		vis[node] = True
		ret = cost[node]
		for i in gr[node]:
			if not vis[i]:
				ret = min(ret, (yield dfs(i)))
		yield ret
	for i in range(n):
		if not vis[i]:
			ans += dfs(i)
	return ans

def cnt(x):
	res = 0
	i = 5
	while i <= x:
		res += x // i
		i *= 5
	return res
_T_ = 1
for _t_ in range(_T_):
	n = inin()
	low = 1
	high = int(1000000000000000.0)
	ansleft = 0
	ansright = 0
	while low <= high:
		mid = (low + high) // 2
		srch = cnt(mid)
		if srch == n:
			ansleft = mid
			high = mid - 1
		elif srch > n:
			high = mid - 1
		else:
			low = mid + 1
	low = 1
	high = int(1000000000000000.0)
	while low <= high:
		mid = (low + high) // 2
		srch = cnt(mid)
		if srch == n:
			ansright = mid
			low = mid + 1
		elif srch > n:
			high = mid - 1
		else:
			low = mid + 1
	if ansleft == ansright == 0:
		print(0)
		break
	print(ansright - ansleft + 1)
	print(*[i for i in range(ansleft, ansright + 1)])


m = int(input())
n = 0
c5 = 0
while c5 < m:
	n += 5
	temp = n
	while temp % 5 == 0:
		c5 += 1
		temp //= 5
if c5 > m:
	print(0)
else:
	print(5)
	for i in range(5):
		print(n + i, end=' ')


n = int(input())
count = 0
i = 0
while count < n:
	i += 1
	k = i
	while k % 5 == 0:
		count += 1
		k = k // 5
if count == n:
	print(5)
	for l in range(5):
		print(i + l, end=' ')
else:
	print(0)


m = int(input())
l = [1]
i = 1
l1 = [i]
l2 = 0
while i < 100000:
	i += 1
	l2 = 5 * i
	c = 0
	while l2 % 5 == 0:
		l2 = l2 // 5
		c += 1
	l.append(l[-1] + c)
	l1.append(i)
if m not in l:
	print(0)
else:
	print(5)
	ind = l.index(m)
	i1 = 5 * l1[ind]
	print(i1, i1 + 1, i1 + 2, i1 + 3, i1 + 4, end=' ')


n = int(input())
lo = 0
hi = int(1e+25)
while lo <= hi:
	mid = (lo + hi) // 2
	i = 5
	num0 = 0
	while True:
		if i > mid:
			break
		num0 += mid // i
		i *= 5
	if num0 > n:
		hi = mid - 1
	else:
		lo = mid + 1
i = 5
num0 = 0
while True:
	if i > hi:
		break
	num0 += hi // i
	i *= 5
if num0 != n:
	print(0)
	exit()
print(5)
for i in range(hi - 4, hi + 1):
	print(i, end=' ')


n = int(input())
p = 0
i = 0
while p < n:
	i += 5
	t = i
	while t % 5 == 0:
		p += 1
		t /= 5
if p == n:
	print(5)
	for z in range(5):
		print(i + z, end=' ')
else:
	print(0)


m = int(input())
zeros = {}
z = 0
i = 5
while z <= m:
	i_temp = i
	while i_temp % 5 == 0:
		i_temp //= 5
		z += 1
	zeros[z] = i
	i += 5
z = zeros.get(m, None)
if z is None:
	print(0)
else:
	x = m + 1
	while zeros.get(x, None) is None:
		x += 1
	print(5)
	for i in range(zeros[m], zeros[x]):
		print(i, end=' ')
	print()


import sys
import math
input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())
n = inp()
import math

def count(a):
	sum = 0
	i = 1
	while math.floor(a / 5.0 ** i) > 0:
		sum = sum + math.floor(a / 5.0 ** i)
		i = i + 1
	return sum
i = 1
ct = 0
s = []
while count(i) < n + 1:
	if count(i) == n:
		s.append(str(i))
		ct = ct + 1
	i = i + 1
print(ct)
if len(s) > 0:
	print(' '.join(s))


a = int(input())

def gh(x):
	k = 0
	p = 5
	while x >= p:
		k += x // p
		p *= 5
	if k > a:
		return 1
	elif k == a:
		return 2
	else:
		return 0
lo = 0
hi = 500000
ans = -1
while lo <= hi:
	mid = (lo + hi) // 2
	ok = gh(mid)
	if ok == 1:
		hi = mid - 1
	elif ok == 2:
		ans = mid
		break
	else:
		lo = mid + 1
if ans == -1:
	print(0)
else:
	print(5)
	f = ans // 5
	for i in range(5):
		print(5 * f + i, end=' ')


def cnt_zeroes(n):
	p5 = 1
	i = 0
	while 5 * p5 <= n:
		p5 *= 5
		i += 1
	ans = 0
	all_cnt = 0
	while p5 > 1:
		ans += i * (n // p5 - all_cnt)
		all_cnt += n // p5 - all_cnt
		p5 //= 5
		i -= 1
	return ans

def bin_search(n):
	l = 1
	r = 1000000
	while r - l > 1:
		m = (l + r) // 2
		if cnt_zeroes(m) < n:
			l = m + 1
		else:
			r = m
	if cnt_zeroes(l) == n:
		return l
	else:
		return r
n = int(input())
f = bin_search(n)
if cnt_zeroes(f) == n:
	print(5)
	for x in range(f, f + 5):
		print(x, end=' ')
	print()
else:
	print(0)


m = int(input())
a = [0] * 500001
for i in range(1, 500001):
	n = 0
	x = i
	while x % 5 == 0:
		x //= 5
		n += 1
	a[i] = a[i - 1] + n
good = 0
g = []
for i in range(500001):
	if a[i] == m:
		good += 1
		g.append(i)
print(good)
for elem in g:
	print(elem, end=' ')


def main():
	n = int(input())
	first = solver(n)
	if first == None:
		print(0)
	else:
		print(5)
		for x in range(first, first + 5):
			print(x)

def solver(n):
	multiplier = 1
	while trailingZeros(multiplier) <= n:
		multiplier *= 5
	lo = multiplier // 5
	hi = multiplier
	while lo < hi:
		mid = (lo + hi) // 2
		zeros = trailingZeros(mid)
		if zeros < n:
			lo = mid + 1
		elif zeros >= n:
			hi = mid
	if trailingZeros(lo) != n:
		return None
	else:
		return lo

def trailingZeros(n):
	count = 0
	fives = 5
	while fives <= n:
		count += n // fives
		fives *= 5
	return count
main()


import collections, itertools, fractions, functools, heapq, math, queue, operator

def fac0(n):
	r = 0
	f = 1
	for i in range(2, n + 1):
		f *= i
		while f % 10 == 0:
			f //= 10
			r += 1
		f %= 1000000
	return r

def result(n, z):
	r = []
	for i in range(max(1, n - 5), n + 5):
		if fac0(i) == z:
			r.append(i)
	print(len(r))
	print(*r)

def solve(n):
	lo = 1
	hi = 500000
	while lo <= hi:
		mid = (lo + hi) // 2
		r = fac0(mid)
		if r == n:
			result(mid, n)
			return
		elif r < n:
			lo = mid + 1
		elif r > n:
			hi = mid - 1
	print(0)
solve(int(input()))


from math import *
n = int(input())
per = 0
per2 = 5
cou = 0
cou2 = 1
while per < n:
	cou2 += 1
	while per2 % 5 == 0:
		per2 = per2 // 5
		per += 1
	if per == n:
		cou = 1
		per2 = (cou2 - 1) * 5
		break
	per2 = cou2 * 5
if cou == 1:
	print(5)
	print(per2, per2 + 1, per2 + 2, per2 + 3, per2 + 4)
else:
	print(0)


n = int(input())
ans = 0
cnt = 0
numbers = []
i = 1
while cnt <= n:
	j = i
	while not j % 5:
		j //= 5
		cnt += 1
	if cnt == n:
		ans += 1
		numbers.append(i)
	i += 1
if ans:
	print(ans, ' '.join(list(map(str, numbers))), sep='\n')
else:
	print(ans)


import sys
from math import log
m = int(input())
number_of_zeroes = 0
for i in range(5, 100000 * 5, 5):
	k = i
	while k % 5 == 0:
		number_of_zeroes += 1
		k //= 5
	if number_of_zeroes == m:
		print(5)
		for j in range(0, 5):
			print(i + j, end=' ')
		sys.exit(0)
	elif m < number_of_zeroes:
		break
print(0)


import time
import math
n = int(input())
start = time.time()
i = 0
results = []
c = [5 ** i for i in range(1, 9)]

def powers(n):
	res = 0
	for i in range(len(c)):
		res += math.floor(n / c[i])
	return res
while True:
	i += 1
	k = powers(i)
	if k == n:
		results.append(i)
	if k > n:
		break
end = time.time()
print(len(results))
if len(results) != 0:
	print(' '.join(list(map(str, results))))


m = int(input())
from math import log

def f5_pow(i):
	k = 0
	while not i % 5:
		i = int(i / 5)
		k = k + 1
	return k
r = 0
i = 0
k = 1
while r < m:
	i = i + 5
	r = r + f5_pow(i)
if r > m:
	print(0)
	exit()
print(5)
print(i, i + 1, i + 2, i + 3, i + 4)


import math as mt
import sys, string, bisect
input = sys.stdin.readline
from collections import deque, defaultdict
L = lambda : list(map(int, input().split()))
Ls = lambda : list(input().split())
M = lambda : map(int, input().split())
I = lambda : int(input())

def numzeroes(n):
	k = 5
	c = 0
	while n // k != 0:
		c += n // k
		k *= 5
	return c
d = defaultdict(list)
n = I()
i = 0
k = 0
while i <= n:
	l = [i for i in range(k, k + 5)]
	d[numzeroes(l[0])] = l
	k += 5
	i = numzeroes(l[0])
print(len(d[n]))
if len(d[n]) != 0:
	print(*d[n])


m = int(input())
(x, z) = (5, 0)
while z < m:
	n = x
	while n % 5 == 0:
		z += 1
		n /= 5
	x += 5
print(f'{5}\n{x - 5} {x - 4} {x - 3} {x - 2} {x - 1}' if z == m else 0)


m = int(input())
k = 5 * m
while k >= 4 * m:
	(s, i) = (k // 5, 2)
	p = k // pow(5, i)
	while p:
		(s, i) = (s + p, i + 1)
		p = k // pow(5, i)
	if s == m:
		break
	k -= 5
if k < 4 * m:
	print(0)
else:
	print(5)
	print(k, k + 1, k + 2, k + 3, k + 4)


from itertools import count
n = int(input())
twos = 0
fives = 0
ans = []

def p_in_num(p, num):
	coun = 0
	while num % p == 0:
		num //= p
		coun += 1
	return coun
for i in count(2):
	twos += p_in_num(2, i)
	fives += p_in_num(5, i)
	zeroes = min(twos, fives)
	if zeroes == n:
		ans.append(i)
	elif zeroes > n:
		break
print(len(ans))
if len(ans) != 0:
	print(*ans)


def zero(n):
	u = 0
	v = 5
	while n // v > 0:
		u += n // v
		v *= 5
	return u
m = int(input())
(l, r, val) = (0, m, 0)
while l <= r:
	mid = l + r >> 1
	u = zero(mid * 5)
	if u == m:
		val = mid * 5
		break
	elif u > m:
		r = mid - 1
	else:
		l = mid + 1
if val > 0:
	print(5)
print(val, end=' ')
if val > 0:
	print(val + 1, val + 2, val + 3, val + 4)


def kol(h):
	ans = 0
	for i in d:
		if h >= i:
			ans += h // i
	return ans
n = int(input())
d = [5 ** i for i in range(1, 20)]
le = 1
ri = 10 ** 9
l = -1
g = []
while le + 1 < ri:
	m = (le + ri) // 2
	ans = kol(m)
	if ans > n:
		ri = m
	elif ans == n:
		l = m
		break
	else:
		le = m
if l == -1:
	print(0)
else:
	t = l + 1
	g = [l]
	while kol(t) == n:
		g.append(t)
		t += 1
	t = l - 1
	while kol(t) == n:
		g.append(t)
		t -= 1
	g.sort()
	print(len(g))
	print(*g)


m = int(input())
r = 0
l = 1
n = 0
k = 0
L = []
while n <= m:
	k += 1
	l *= k
	while l % 10 == 0:
		n += 1
		l = l // 10
	l = int(str(l)[len(str(l)) // 3:])
	if n == m:
		r += 1
		L += [k]
if r == 0 or r == 5:
	print(r)
	for i in range(r):
		print(L[i], end=' ')
else:
	print(0)


def zeroes(x):
	n = 0
	while x:
		d = x // 5
		n += d
		x = d
	return n
m = int(input())
i = 0
j = 500000
while j - i > 1:
	k = (i + j) // 2
	n = zeroes(k)
	if n < m:
		i = k
	elif n > m:
		j = k
	else:
		k = k // 5 * 5
		print(5)
		print(' '.join([str(k + i) for i in range(5)]))
		break
else:
	print(0)


import math
m = int(input())
c = 0
s = 0
k = 0
while c < m:
	s += 5
	s1 = s
	k = 0
	while s1 % 5 == 0:
		k += 1
		s1 /= 5
	c += k
if c == m:
	a = list(range(s, s + 5))
	print(5)
	print(*a)
else:
	print(0)


m = int(input())
num = 0
x = 0
while x < m:
	num += 5
	tmp = num
	while tmp % 5 == 0:
		x += 1
		tmp = tmp // 5
	if x == m:
		break
if x == m:
	print(5)
	for i in range(5):
		print(num + i, end=' ')
	print()
else:
	print(0)


def main():
	m = int(input())
	zc = 0
	i = 0
	while zc < m:
		i += 5
		cr = i
		while cr % 5 == 0:
			zc += 1
			cr = int(cr / 5)
	if zc == m:
		print(5)
		ans = []
		for k in range(i, i + 5):
			ans.append(str(k))
		print(' '.join(ans))
	else:
		print(0)
main()


n = int(input())

def zrs(n):
	ret = 0
	while n >= 5:
		n //= 5
		ret += n
	return ret

def bins(n):
	(a, b) = (1, n * 5 + 1)
	while a < b:
		mid = (a + b) // 2
		guess = zrs(mid)
		if guess < n:
			a = mid + 1
		elif guess > n:
			b = mid - 1
		else:
			return mid
	return 0
x = bins(n)
x = x - x % 5
if x == 0:
	print('0')
else:
	print('5')
	print(' '.join(map(str, range(x, x + 5))))


readInts = lambda : list(map(int, input().split()))
n = int(input())
for i in range(1, 500000):
	cnt = 0
	t = i
	while t > 0:
		cnt += t // 5
		t //= 5
	if cnt == n:
		print(5)
		for j in range(i, i + 5):
			print(j, end=' ')
		exit(0)
print(0)


from math import *
sInt = lambda : int(input())
mInt = lambda : map(int, input().split())
lInt = lambda : list(map(int, input().split()))

def trz(n):
	i = 5
	ans = 0
	while n // i > 0:
		ans += n // i
		i *= 5
	return ans
n = sInt()
a = []
j = 5
while True:
	if trz(j) == n:
		a.append(j)
	elif trz(j) > n:
		break
	j += 1
print(len(a))
print(*a, sep=' ')


a = int(input())
tot = 0
l = []
z = 0
for i in range(1, 500000):
	x = i
	while x % 5 == 0:
		z += 1
		x //= 5
	if a == z:
		tot += 1
		l.append(i)
	if a < z:
		break
print(tot)
print(' '.join(map(str, l)))


import sys

def cnt(x):
	ret = 0
	while x > 0:
		ret += x // 5
		x //= 5
	return ret
want = int(input())
a = []
for x in range(1, 5 * 10 ** 5):
	if cnt(x) == want:
		a.append(x)
print(len(a))
for x in a:
	print(x, end=' ')


a = int(input())
t = []
num = 1
two = 0
five = 0
counter = 0
k = 0
while k <= a:
	if k == a:
		counter = counter + 1
		t.append(num - 1)
	s = num
	while s % 2 == 0:
		two += 1
		s = s / 2
	while s % 5 == 0:
		five += 1
		s = s / 5
	while two > 0 and five > 0:
		k = k + 1
		two = two - 1
		five = five - 1
	num = num + 1
print(counter)
for i in t:
	print(i, end=' ')


def main():
	n = int(input())
	if not n:
		print('4\n1 2 3 4')
		return
	(le, p) = ((n + 1) * 5, 5)
	l = [0] * le
	while p < le:
		for i in range(p, le, p):
			l[i] += 1
		p *= 5
	(p, res) = (0, [])
	for (i, a) in enumerate(l):
		p += a
		if p == n:
			res.append(i)
	print(len(res))
	if res:
		print(*res)
main()


def findTrailingZeros(n):
	count = 0
	i = 5
	while n / i >= 1:
		count += int(n / i)
		i *= 5
	return int(count)
m = int(input())
n = 0
ans = 0
flag = 0
while True:
	if ans == m:
		flag = 1
		break
	elif ans > m:
		flag = -1
		break
	else:
		n += 5
		ans = findTrailingZeros(n)
if flag == 1:
	print(5)
	print(*list(range(n, n + 5)))
else:
	print(0)


from sys import *
inp = lambda : stdin.readline()

def get(a):
	if a < 5:
		return 0
	return a // 5 + get(a // 5)

def main():
	d = {}
	for i in range(5, 1000000, 5):
		d[get(i)] = i
	n = int(inp())
	if n in d:
		print('5')
		for i in range(5):
			print(d[n] + i, end=' ')
	else:
		print(0)
main()


__author__ = 'Utena'

def t(x):
	c = 0
	if x % 5 == 0:
		return t(x // 5) + 1
	else:
		return 0
m = int(input())
i = 5
n = 0
c = []
t1 = 0
while True:
	n += t(i)
	if n == m:
		t1 += 1
		c.append(str(i))
	if n > m:
		break
	i += 1
if t1 == 0:
	print(0)
else:
	print(t1)
	print(' '.join(c))


def find(n):
	res = 0
	while n:
		res += n // 5
		n //= 5
	return res

def binsearch(m):
	low = 1
	high = 1000000
	while low < high:
		mid = (low + high) // 2
		if find(mid) < m:
			low = mid + 1
		else:
			high = mid
	return high
m = int(input())
low = binsearch(m)
high = binsearch(m + 1)
res = [i for i in range(low, high)]
if res:
	print(len(res))
	print(' '.join([str(x) for x in res]))
else:
	print(0)


import io, os
import sys
from math import log
from atexit import register
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
sys.stdout = io.BytesIO()
register(lambda : os.write(1, sys.stdout.getvalue()))
tokens = []
tokens_next = 0

def nextStr():
	global tokens, tokens_next
	while tokens_next >= len(tokens):
		tokens = input().split()
		tokens_next = 0
	tokens_next += 1
	return tokens[tokens_next - 1]

def nextInt():
	return int(nextStr())

def nextIntArr(n):
	return [nextInt() for i in range(n)]

def print(s, end='\n'):
	sys.stdout.write((str(s) + end).encode())

def countFivesInFac(n):
	res = 0
	i = 5
	while n / i >= 1:
		res += n // i
		i *= 5
	return res

def solve(m):
	low = 1
	high = 10 ** 6
	while low + 1 < high:
		mid = (low + high) // 2
		if countFivesInFac(mid) < m:
			low = mid
		else:
			high = mid
	return list(range(high, high + 5)) if countFivesInFac(high) == m else []
m = nextInt()
res = solve(m)
print(len(res))
print(' '.join(map(str, res)))