import java.util.HashMap;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner kb = new Scanner(System.in);
String number = kb.next();
HashMap<Character, Integer> map = new HashMap<>();
for(int i=0; i<number.length(); i++) {
char digit = number.charAt(i);
map.put(digit, map.getOrDefault(digit, 0)+1);
}
int count6 = map.getOrDefault('6', 0);
int count9 = map.getOrDefault('9', 0);
map.put('6', (count6 + count9 + 1)/2);
map.remove('9');
int max = 0;
for(int count: map.values()) {
max = Math.max(max, count);
}
System.out.println(max);
}
}