#include <iostream>
#include <string>
#include <vector>


using namespace std;

vector<string> target = {"BOB", "BOb", "BoB", "Bob", "bOB", "bOb", "boB", "bob"};
int main() {
    string s;
    cin >> s;
    bool st = false;
    unsigned long idx = 101;
    for (int i = 0; i < 8; i++) {
        string t = target[i];
        auto id = s.find(t);
        if (id != string :: npos) {
            idx = min(id,idx);
            st = true;
        }
    }
    if(!st){
        cout<<-1;
    }else{
        cout<<idx;
    }

}
// 64 位输出请用 printf("%lld")