using System; using System.Collections.Generic; class SwapString { static void Main(String[] args) { String S = Console.ReadLine(); Queue countQueue = new Queue(); Queue uniqueQueue = new Queue(); countQueue.Enqueue(S); uniqueQueue.Enqueue(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(!uniqueQueue.Contains(t)) { countQueue.Enqueue(t); uniqueQueue.Enqueue(t); } } } Console.WriteLine(uniqueQueue.Count-1); } }