#!/usr/bin/env python3 import sys # rather than keep a raw list, count number of each type! counts = [0] * 9 for l in sys.stdin: for f in l.split(","): counts[int(f)] += 1 for i in range(256): ready = counts.pop(0) counts[6] += ready counts.append(ready) print(sum(counts))