Problem: A very tense moment: n cowboys stand in a circle and each one points his colt at a neighbor. Each cowboy can point the colt to the person who follows or precedes him in clockwise direction. Human life is worthless, just like in any real western.

The picture changes each second! Every second the cowboys analyse the situation and, if a pair of cowboys realize that they aim at each other, they turn around. In a second all such pairs of neighboring cowboys aiming at each other turn around. All actions happen instantaneously and simultaneously in a second.

We'll use character "A" to denote a cowboy who aims at his neighbour in the clockwise direction, and character "B" for a cowboy who aims at his neighbour in the counter clockwise direction. Then a string of letters "A" and "B" will denote the circle of cowboys, the record is made from the first of them in a clockwise direction.

For example, a circle that looks like "ABBBABBBA" after a second transforms into "BABBBABBA" and a circle that looks like "BABBA" transforms into "ABABB".

<image> This picture illustrates how the circle "BABBA" transforms into "ABABB" 

A second passed and now the cowboys' position is described by string s. Your task is to determine the number of possible states that lead to s in a second. Two states are considered distinct if there is a cowboy who aims at his clockwise neighbor in one state and at his counter clockwise neighbor in the other state.

Input

The input data consists of a single string s. Its length is from 3 to 100 characters, inclusive. Line s consists of letters "A" and "B".

Output

Print the sought number of states.

Examples

Input

BABBBABBA


Output

2


Input

ABABB


Output

2


Input

ABABAB


Output

4

Note

In the first sample the possible initial states are "ABBBABBAB" and "ABBBABBBA".

In the second sample the possible initial states are "AABBB" and "BABBA".

Solution (in JAVA):

Solution:
import java.util.*;
import java.io.*;

public class C {
    
    static int n;
    static int[] seq;
    static long[][] dp;
    
    public static void main(String[] args) throws IOException {
        Kattio in = new Kattio(System.in);
        String s = in.getWord();
        n = s.length();
        seq = new int[s.length()];
        for (int i = 0; i < n; i++) {
            seq[i] = s.charAt(i) - 'A';
        }
        dp = new long[n][2];
        for (int i = 0; i < n; i++) {
            Arrays.fill(dp[i], -1);
        }
        long res = 0;
        res += solve(0, seq[0]);
        if (seq[0] == 0 && seq[n - 1] == 1) {
            for (int i = 0; i < n; i++) {
                Arrays.fill(dp[i], -1);
            }
            n--;
            res += solve(1, 0);
        }
        System.out.println(res);
    }
    
    static long solve(int pos, int first) {
        if (pos >= n) return 1;
        if (pos == n - 1) {
            if (first == 1 && seq[pos] == 0) return 0;
            return 1;
        }
        if (dp[pos][first] != -1) return dp[pos][first];
        long res = 0;
        int curr = seq[pos];
        int next = seq[pos+1];
        if (curr == 0 && next == 1) {
            if (pos + 2 >= n) return 0;
            int third = seq[pos + 2];
            if (third == 0) res += solve(pos + 3, first);
        } else {
            res += solve(pos + 1, first);
            if (curr == 1 && next == 0) {
                res += solve(pos + 2, pos == 0 ? 0 : first);
            }
        }
        return dp[pos][first] = res;
    }
    

    static class Kattio extends PrintWriter {
        public Kattio(InputStream i) {
        super(new BufferedOutputStream(System.out));
        r = new BufferedReader(new InputStreamReader(i));
        }
        public Kattio(InputStream i, OutputStream o) {
        super(new BufferedOutputStream(o));
        r = new BufferedReader(new InputStreamReader(i));
        }

        public boolean hasMoreTokens() {
        return peekToken() != null;
        }

        public int getInt() {
        return Integer.parseInt(nextToken());
        }

        public double getDouble() { 
        return Double.parseDouble(nextToken());
        }

        public long getLong() {
        return Long.parseLong(nextToken());
        }

        public String getWord() {
        return nextToken();
        }



        private BufferedReader r;
        private String line;
        private StringTokenizer st;
        private String token;

        private String peekToken() {
        if (token == null) 
            try {
            while (st == null || !st.hasMoreTokens()) {
                line = r.readLine();
                if (line == null) return null;
                st = new StringTokenizer(line);
            }
            token = st.nextToken();
            } catch (IOException e) { }
        return token;
        }

        private String nextToken() {
        String ans = peekToken();
        token = null;
        return ans;
        }
    }
}