from collections import Counter import math N = input().replace('9','6') CT = Counter(N) if '6' in CT: CT['6'] = math.ceil(CT['6']/2) print(max(CT.values()))