import java.util.*;
public class Main {
public static void main
(String[] args
) { final Scanner sc
= new Scanner
(System.
in); while(sc.hasNext()) {
final char[] s = sc.next().toCharArray();
if(s[0] == '#')
return;
final Set<String> set = new TreeSet<String>();
dfs(s, 0, set, new boolean[128]);
System.
out.
println(set.
size()); int i = 0;
if(i < 5 || set.size() - 5 <= i)
i++;
}
}
}
private static void dfs(final char[] cs, final int i, final Set<String> set, final boolean[] flags) {
if(i == cs.length){
return;
}
if(!flags[cs[i] + 1] && cs[i] < 'z') {
flags[++cs[i]] = true;
dfs(cs, i + 1, set, flags);
flags[cs[i]--] = false;
}
if(cs[i] == 'a' || flags[cs[i]]) {
dfs(cs, i + 1, set, flags);
}
}
}
aW1wb3J0IGphdmEudXRpbC4qOwpwdWJsaWMgY2xhc3MgTWFpbiB7CiAgcHVibGljIHN0YXRpYyB2b2lkIG1haW4oU3RyaW5nW10gYXJncykgewogICAgZmluYWwgU2Nhbm5lciBzYyA9IG5ldyBTY2FubmVyKFN5c3RlbS5pbik7CiAgICB3aGlsZShzYy5oYXNOZXh0KCkpIHsKICAgICAgZmluYWwgY2hhcltdIHMgPSBzYy5uZXh0KCkudG9DaGFyQXJyYXkoKTsKICAgICAgaWYoc1swXSA9PSAnIycpCiAgICAgICAgcmV0dXJuOwogICAgICBmaW5hbCBTZXQ8U3RyaW5nPiBzZXQgPSBuZXcgVHJlZVNldDxTdHJpbmc+KCk7CiAgICAgIGRmcyhzLCAwLCBzZXQsIG5ldyBib29sZWFuWzEyOF0pOwogICAgICBTeXN0ZW0ub3V0LnByaW50bG4oc2V0LnNpemUoKSk7CiAgICAgIGludCBpID0gMDsgCiAgICAgIGZvcihmaW5hbCBTdHJpbmcgc3MgOiBzZXQpIHsKICAgICAgICBpZihpIDwgNSB8fCBzZXQuc2l6ZSgpIC0gNSA8PSBpKQogICAgICAgICAgU3lzdGVtLm91dC5wcmludGxuKHNzKTsKICAgICAgICBpKys7CiAgICAgIH0KICAgIH0KICB9CiAgcHJpdmF0ZSB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