//No.52 よくある文字列の問題 import java.util.*; import java.io.*; import static java.util.Arrays.*; import static java.lang.Math.*; public class No52 { static final Scanner in = new Scanner(System.in); static final PrintWriter out = new PrintWriter(System.out,false); static void solve() { String s = in.next(); char[] cs = s.toCharArray(); int cnt = 0; sort(cs); do { String t = String.valueOf(cs); if (dfs(t,s,0)) cnt++; }while(nextPermutation(cs)); out.println(cnt); } static boolean dfs(String s, String t, int idx) { char c = s.charAt(idx); int len = t.length(); if (len == 1) return c == t.charAt(0); if (t.charAt(0) == c && dfs(s,t.substring(1),idx+1)) return true; if (t.charAt(len-1) == c && dfs(s,t.substring(0,len-1),idx+1)) return true; return false; } static boolean nextPermutation(char[] a) { int n = a.length, i, j; for (i=n-2; i>=0 && a[i]>=a[i+1]; i--); if (i == -1) return false; for (j=i+1; j