#include <iostream>
using namespace std;
string s;
bool nigger() {
    for (int i = 1; i < s.size(); i++) if (s[i] != s[0]) return false;
    return true;
}
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> s;
    if (nigger()) cout << s.size() - 1 << endl;
    else cout << 0 << endl;
}