#include <bits/stdc++.h>

using namespace std;
vector<int> poz[26];

int memo[26][1000007];

long long solve(int letter, int pointer) {
    if (memo[letter][pointer] != 0)
        return memo[letter][pointer];
    int nextCandidate = upper_bound(poz[letter].begin(), poz[letter].end(), pointer) - poz[letter].begin();
    if (nextCandidate == poz[letter].size())
        return -1;
    if (letter == 25)
        return poz[letter].size() - nextCandidate;
    long long result = 0, sr;
    for (int i = nextCandidate; i < poz[letter].size(); i++) {
        sr = solve(letter + 1, poz[letter][i]);
        if (sr != -1) {
            result = (result + sr) % (1000000007);
        }
    }
    memo[letter][pointer] = result;
    return result;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    string s;
    cin >> s;
    for (int i = 0; i < 26; i++)
        poz[i].reserve(s.length() / 26 + 1);
    for (int i = 0; i < s.length(); i++) {
        poz[s[i] - 'A'].push_back(i);
    }
    cout << solve(0, -1);
    return 0;
}