#include using namespace std; using ll = long long; #define rep(i,m,n) for(int i=m; i bool chmin(T& a, T b){ if(a > b){a = b; return true;} return false; } template bool chmax(T& a, T b){ if(a < b){a = b; return true;} return false; } template T gcd(T a, T b){ return a % b ? gcd(b, a % b) : b; } template T lcm(T a, T b){ return a / gcd(a, b) * b; } int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); string S; cin >> S; int n = S.size(); queue q; q.push(S); map dis; dis[S] = 0; while(q.size()){ string v = q.front(); q.pop(); rep(i, 0, n-1){ string nv = v; swap(nv[i], nv[i+1]); if(!dis.count(nv)){ dis[nv] = dis[v] + 1; q.push(nv); } } } int ans = 0; for(auto[s, i] : dis) if(i > 0) ++ans; cout << ans << endl; return 0; }