#include using namespace std; #ifdef LOCAL #include "settings/debug.cpp" #else #define Debug(...) void(0) #endif #define rep(i, n) for (int i = 0; i < (n); ++i) using ll = long long; using ull = unsigned long long; int main() { string s; cin >> s; int n = s.size(); int ans = 0; for (int i = 0; i < n; ++i) { for (int j = n - 1; j > i; --j) { if (s[j] < s[j - 1]) { swap(s[j], s[j - 1]); ++ans; } } } cout << ans << endl; return 0; }