using System; using System.Collections.Generic; class SwapString { static void Main(String[] args) { String S = Console.ReadLine(); Queue countQueue = new Queue(); HashSet countHash = new HashSet(); countQueue.Enqueue(S); countHash.Add(S); while(countQueue.Count > 0) { String s = countQueue.Dequeue(); for(int i=0; i < s.Length-1; i++) { char[] arr = s.ToCharArray(); char temp = arr[i+1]; arr[i+1] = arr[i]; arr[i] = temp; String t = new String(arr); if(countHash.Add(t)) { countQueue.Enqueue(t); } } } Console.WriteLine(countHash.Count-1); } }