aaaaabb
 aabaaaa
 babbabaabbbbabwbvbhbbbaaabbabbbbbbbkabbbbabaaabbbbbbajabbaaabazbbbzbalbabbwbbaabbabacabdbabbbfaaabbb
 baaahbbbba
 ababavvvv
 abnxabbaab
 krflnzhter
 amaabbbbxaabbbabaabaabbaaabaaaaabibbabaabaaabaabcaaxabablbbbbmbbbaaaaaabbaabbbaaabaaaababaababbabbbb
 babbbaaaaaabbbaabaaaaaoaabababaababaaaaababaaaaaaabbbbbbaaapaabaaabaaababaaaabaaaabaaaaababaaaabaaab

5
 14
 42467327
 7
 7
 11
 0
 98718509
 813881762

import java.util.Random;
import java.util.Scanner;

public class Main {


    static int mod = (int)(1E7 + 1);
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String s = scanner.next();
        if(s.length() == 0){
            System.out.println(0);
            return;
        }
        if(s.charAt(s.length() - 1) != 'b')
            s += 'b';

        int n = s.length();

        int subsec = 0, a = 0;
        for (int i = 0; i < n; i++) {
            if(s.charAt(i) == 'a'){
                a++;
            } else if(s.charAt(i) == 'b'){
                long x = ((long) subsec * (long) a) % mod;
                long y = ((long) subsec + x) % mod;
                long z = (y + (long) a) % mod;
                subsec = (int)z;
                a = 0;
            }
        }
        System.out.println(subsec);
        
    }
}