You have number *a*, whose decimal representation quite luckily contains digits 1, 6, 8, 9. Rearrange the digits in its decimal representation so that the resulting number will be divisible by 7.

Number *a* doesn't contain any leading zeroes and contains digits 1, 6, 8, 9 (it also can contain another digits). The resulting number also mustn't contain any leading zeroes.
The first line contains positive integer *a* in the decimal record. It is guaranteed that the record of number *a* contains digits: 1, 6, 8, 9. Number *a* doesn't contain any leading zeroes. The decimal representation of number *a* contains at least 4 and at most 10<sup class="upper-index">6</sup> characters.
n = input()
used = [0 for i in range(10)]
s = "0"
k = 0
for i in range(len(n)):
	if (n[i] == '1' or n[i] == '6' or n[i] == '8' or n[i] == '9'):
		if (used[int(n[i])]):
			s += n[i]
	elif (n[i] == '0'):
		k += 1
	else:
		s += n[i]
s = int(s)
if (s != 0):
	print(s, end = '')
if (s % 7 == 0):
	print('1869', end = '')
if (s % 7 == 1):
	print('1968', end = '')
if (s % 7 == 2):
	print('1689', end = '')
if (s % 7 == 3):
	print('6891', end = '')
if (s % 7 == 4):
	print('1698', end = '')
if (s % 7 == 5):
	print('1986', end = '')
if (s % 7 == 6):
	print('1896', end = '')
for i in range(k):
	print('0', end = '')

