def main():
    shopping_list = {}
    while True:
        try:
            item = input("").upper()
        except EOFError:
            break
        if item not in shopping_list:
            shopping_list[item] = 0
        shopping_list[item] += 1
    for item, quantity in sorted(shopping_list.items(), key=lambda x: x[0]):
        print(f"{quantity} {item}")


if __name__ == "__main__":
    main()
