import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String map = sc.next();
        int leftSteps = 0;
        int rightSteps = 1;
        for (char c : map.toCharArray()) {
            switch (c) {
                case 'L':
                    leftSteps = Math.min(rightSteps+1, leftSteps+1);
                    break;
                case 'R':
                    rightSteps = Math.min(rightSteps+1, leftSteps+1);
                    break;
                case 'B':
                    leftSteps++;
                    rightSteps++;
                    break;
                default:
                    throw new RuntimeException("Error input: " + map);
            }
        }
        System.out.println(rightSteps);
    }

}