D ={ i:0 for i in range(9) }
for l in list(map(int,__import__("sys").stdin.read().split(","))):
D[l]+=1
for i in range(256):
D = { i-1:D[i] for i in range(9) }
D[6] += D[-1]
D[8] = D[-1]
del D[-1]
print(sum(D.values()))