aaaaabb
 aabaaaa
 babbabaabbbbabwbvbhbbbaaabbabbbbbbbkabbbbabaaabbbbbbajabbaaabazbbbzbalbabbwbbaabbabacabdbabbbfaaabbb
 baaahbbbba
 ababavvvv
 abnxabbaab
 krflnzhter
 amaabbbbxaabbbabaabaabbaaabaaaaabibbabaabaaabaabcaaxabablbbbbmbbbaaaaaabbaabbbaaabaaaababaababbabbbb
 babbbaaaaaabbbaabaaaaaoaabababaababaaaaababaaaaaaabbbbbbaaapaabaaabaaababaaaabaaaabaaaaababaaaabaaab

5
 14
 42467327
 7
 7
 11
 0
 98718509
 813881762

import java.io.*;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;

import static java.lang.Math.*;

public class Main {
    FastScanner in;
    PrintWriter out;

    void run() {
        in = new FastScanner();
        out = new PrintWriter(System.out);
        problem();
        out.close();
    }

    class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public FastScanner(String s) {
            try {
                br = new BufferedReader(new FileReader(s));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }

        public String nextToken() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                }
            }
            return st.nextToken();
        }

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

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

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

    public static void main(String[] args) {
        new Main().run();
    }

    void build (int a[], int v, int tl, int tr) {
        if (tl == tr)
            t[v] = a[tl];
        else {
            int tm = (tl + tr) / 2;
            build(a, v * 2, tl, tm);
            build(a, v * 2 + 1, tm + 1, tr);
            t[v] = t[v * 2] + t[v * 2 + 1];
        }
    }

    int sum (int v, int tl, int tr, int l, int r) {
        if (l > r)
            return 0;
        if (l == tl && r == tr)
            return t[v];
        int tm = (tl + tr) / 2;
        return sum (v*2, tl, tm, l, min(r,tm))
                + sum (v*2+1, tm+1, tr, max(l,tm+1), r);
    }

    public static long modPower(int x, int y)
    {
        if(y==0) return 1;
        long z = modPower(x, y/2);
        if ((y % 2) == 0)
            return (z*z)%N;
        else
            return (x*z*z)%N;
    }

    int [] t;
    static int N = (int)pow(10, 9) + 7;

    class Node {
        int id;
        int w;
        List<Path> p;

        public Node(int id, int w) {
            this.id = id;
            this.w = w;
            p = new ArrayList<>();
        }
    }

    class Path {
        int cost;
        int city;

        public Path(int cost, int city) {
            this.cost = cost;
            this.city = city;
        }
    }

    List<Node> nodes ;

    void problemD() {
        int n = in.nextInt();

        nodes = new ArrayList<>(n);

        for (int i = 0; i < n; i++) {
            nodes.add(new Node(i, in.nextInt()));
        }

        for (int i = 0; i < n - 1; i++) {
            int u = in.nextInt();
            int v = in.nextInt();
            int c = in.nextInt();

            nodes.get(u - 1).p.add(new Path(c, v - 1));
        }


    }


    void problem() {
        String s = in.nextToken();
        List<Integer> a = new ArrayList<>(s.length());

        int t = 0;
        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) == 'a') {
                t++;
            } else if (s.charAt(i) == 'b') {
                if (t > 0) {
                    a.add(t);
                    t = 0;
                }
            }
        }
        if (t > 0) {
            a.add(t);
        }

        if (a.size() == 0) {
            out.println(0);
            return;
        }

        long[] f = new long[a.size()];
        f[0] = a.get(0);
        for (int i = 1; i < a.size(); i++) {
            f[i] = (f[i-1] + 1) * a.get(i) + f[i-1];
        }

        out.println(f[a.size() - 1]);
    }
}
