import java.util.*;
public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Map<String, String> m = new HashMap<>();//字典“1”映射“A”,“26”映射“Z”
        for(int i = 1; i <= 26; ++i){
            StringBuilder sb1 = new StringBuilder();
            StringBuilder sb2 = new StringBuilder();
            sb1.append(i);
            sb2.append((char)('A' + i - 1));
            m.put(String.valueOf(sb1), String.valueOf(sb2));
        }
        while (sc.hasNextLine()) {
            String s = sc.nextLine();
            g(f(s, m));//用方法f求答案,用方法g输出答案
            System.out.println();
        }
    }
    public static List<String> f(String s, Map<String, String> m){
        List<String> r = new ArrayList<>();
        if(s.length() == 1){
            if(m.containsKey(s)) r.add(m.get(s));
            else r.add("0");//不规整的串尾用“0”标记
            return r;
        }
        if(s.length() == 2){
            if(m.containsKey(s)) r.add(m.get(s));
            StringBuilder sb0 = new StringBuilder();
            StringBuilder sb1 = new StringBuilder();
            sb0.append(s.charAt(0));
            sb1.append(s.charAt(1));
            StringBuilder ans = new StringBuilder();
            if(m.containsKey(String.valueOf(sb0))) ans.append(m.get(String.valueOf(sb0)));
            if(m.containsKey(String.valueOf(sb1))) ans.append(m.get(String.valueOf(sb1)));
            if(ans.length() == 2) r.add(String.valueOf(ans));
            else r.add("0");//不规整的串尾用“0”标记
            return r;
        }
        StringBuilder sb0 = new StringBuilder();
        StringBuilder sb1 = new StringBuilder();
        sb0.append(s.charAt(0));
        sb1.append(s.charAt(0));
        sb1.append(s.charAt(1));
        if(m.containsKey(String.valueOf(sb0))){
            StringBuilder rest = new StringBuilder(s.substring(1));
            List<String> bwt = f(String.valueOf(rest), m);
            for(String i : bwt){
                r.add(String.valueOf(new StringBuilder().append(m.get(String.valueOf(sb0))).append(i)));
            }
        }
        if(m.containsKey(String.valueOf(sb1))){
            StringBuilder rest = new StringBuilder(s.substring(2));
            List<String> bwt = f(String.valueOf(rest), m);
            for(String i : bwt){
                r.add(String.valueOf(new StringBuilder().append(m.get(String.valueOf(sb1))).append(i)));
            }
        }
        if((!m.containsKey(String.valueOf(sb0)))&&(!m.containsKey(String.valueOf(sb1)))){
            r.add("0");//不规整的串首用“0”标记
        }
        return r;
    }
    public static void g(List<String> v){//用来处理输出的方法g
        for(int i = 0; i < v.size(); ++i){
            if(v.get(i).length() == 0 || v.get(i).contains("0")){//删除含“0”的串
                v.remove(i);
                --i;
            }
        }
        System.out.print(v.size());
    }
}