import sys from itertools import groupby as gb r = sys.argv[1] for _ in range(int(sys.argv[2])): r = "".join(f'{n}{c}' for c,n in map(lambda x: (x[0],len(list(x[1]))), gb(r))) print(len(r))