#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll iterCount=0,wC=0,bC=0;
  string cad;
  cin>>cad;
  for(int i = 0 ; i < cad.length();i++){
    if(cad[i]=='W') wC++;
    else bC++;
  }
  //cout<<"wC total in string: "<<wC<<endl;
  //cout<<"bC total in string;: "<<bC<<endl;
  //cout<<"_____________________"<<endl;
  for(int i=0; i<wC;i++){
    if(cad[i]=='B'){
      iterCount++;
      //cad[i]='W';
    }
  }
  for(int k =wC ; k < cad.length();k++){
    if(cad[k]=='W'){
      iterCount++;
      //cad[k]='B';
    }
  }
  //cout<<"new string: "<<cad<<endl;
  cout<<iterCount<<endl;
  //cout<<"_____________________"<<endl;
}
