from sys import argv
a = argv[1]
inp = open(f"{a}", "r")
indelcnt = 0
indelchck = 0
indeldict = {}
name = []
spis = []
pisum = 0

for line in inp:
    if not line.startswith("#"):
        line.strip()
        line = line.split()
        if line != []:
            if line[0] in indeldict:
                indeldict[line[0]].append(line[2])
    elif line.startswith("# Aligned_sequences: "):
        line.strip()
        line = line.split()
        num = int(line[2])
        spis = list(range(1, num+1))
    else:
        if spis != []:
            for el in spis:
                if line.startswith(f"# {el}"):
                    line.strip()
                    line = line.split()
                    name = line[2]
                    indeldict[name] = []
                    break
for name in indeldict:
    nam_n = "".join(indeldict[name])
    indeldict[name] = nam_n
for seq in indeldict:
    for el in indeldict[seq]:
        if el != "-":
            indelchck = 0
        else:
            if indelchck == 0:
                indelcnt += 1
            indelchck += 1
    indeldict[seq] = indelcnt
    indelcnt = 0

for p in indeldict:
    print(p, indeldict[p])
    pisum += indeldict[p]
print('Total', pisum)