https://www.acmicpc.net/problem/1475
n=int(input())
k=str(n)
arr=[0]*10
count=0
for i in range(len(k)):
arr[n%10]+=1
n//=10
arr[6]+=arr[9]
arr[9]=0
for i in range(10):
a=0
if i==6:
if arr[i]%2==0: a=arr[i]//2
else: a=(arr[i]//2)+1
else: a=arr[i]
if a>=count: count=a
print(count)