#include <bits/stdc++.h>
using namespace std;
int main() {
string str; cin >> str;
vector<int> points(str.length(), 0);
unordered_set<char> seen;
auto ita = str.rbegin();
auto itb = ita+1;
seen.insert(*ita);
while (ita != str.rend()) {
int bi = str.rend()-itb-1;
if (seen.find(*itb) == seen.end() && itb != str.rend()) {
seen.insert(*itb);
points[bi] += 1;
++itb;
} else {
++ita;
itb = ita+1;
seen.clear();
}
}
for (int i = points.size()-1; i >= 0; --i) {
points[i] += points[i+1];
}
points[points.size()-1] = 1;
int result = 0;
auto itc = str.begin();
auto itd = itc+1;
seen.clear();
seen.insert(*itc);
while (itc != str.end()) {
int di = distance(str.begin(), itd)-1;
cout << *itc << " and " << *itd << endl;
if (seen.find(*itd) == seen.end() && itd != str.end()) {
cout << "YES! i=" << di+1 << endl;
seen.insert(*itd);
result += points[di+1+1]+1;
++itd;
} else {
cout << "fail." << endl;
++itc;
itd = itc+1;
seen.clear();
}
}
if (result%2==1)--result;
cout << result%1000000007 << endl;
}