from itertools import groupby
strs = [x.lower() for x in input() if x.isalpha()]
group = [list(n) for m, n in groupby(strs)] # 按照是否连续进行分组
is_series = [s[0] + str(len(s)) for s in group if len(s) > 1] # 连续字符串按照 字符+数量 格式保存
no_series = []
for i, s in enumerate(group):
if len(s) == 1:
no_series.append((s[0], strs.index(s[0])))
for c, i in no_series: # 不连续字符按照 字符+后续数量 格式保存
c_num = str(strs[i+1:].count(c))
is_series.append(c + c_num)
sorted_is_series = sorted(is_series, key=lambda x: (-int(x[1:]), x[0])) # x[1:]倒序排列, x[0]升序排列
print(*sorted_is_series, sep='')