#include #define ft first #define sc second #define pt(sth) cout << sth << "\n" using namespace std; typedef long long ll; typedef pair pll; templatebool chmax(T &a, const T &b) {if(abool chmin(T &a, const T &b) {if(b> a[i]; struct mll { ll val; mll(ll val=0):val((val%MOD+MOD)%MOD){} mll pow(ll t) const { if (!t) return 1; mll a = pow(t>>1); a *= a; if (t&1) a *= *this; return a; } mll inv() const { return pow(MOD-2); } mll operator-() const { return mll(-val);} mll& operator+=(const mll a) { if ((val += a.val) >= MOD) val -= MOD; return *this; } mll& operator-=(const mll a) { if ((val += MOD-a.val) >= MOD) val -= MOD; return *this; } mll& operator*=(const mll a) { (val *= a.val%MOD) %= MOD; return *this; } mll& operator/=(const mll a) { return (*this) *= a.inv(); } mll operator+(const mll a) const { mll res(*this); return res+=a; } mll operator-(const mll a) const { mll res(*this); return res-=a; } mll operator*(const mll a) const { mll res(*this); return res*=a; } mll operator/(const mll a) const { mll res(*this); return res/=a; } mll& operator++( ) { val++; return *this; } mll operator++(int) { mll res(*this); val++; return res; } mll& operator--( ) { val--; return *this; } mll operator--(int) { mll res(*this); val--; return res; } bool operator< (const mll a) const { return val< a.val; } bool operator<=(const mll a) const { return val<=a.val; } bool operator> (const mll a) const { return val> a.val; } bool operator>=(const mll a) const { return val>=a.val; } bool operator==(const mll a) const { return val==a.val; } friend istream& operator>>(istream &input, mll &a) { input >> a.val; return input; } friend ostream& operator<<(ostream &output, mll &a) { output << a.val; return output;; } }; mll sum[26][MAX*2]={}; int main(void) { ll i, j, k; string s; cin >> s; ll N=s.size(); s='#'+s; pt(s); for(i=1; i<=N; i++) { sum[s[i]-'a'][i]+=sum[s[i]-'a'][i-1]+mll(2).pow(i-1); } mll ans=0; for(j=1; j<=N; j++) { for(ll p=0; p<26; p++) { if(p==s[j]-'a') continue; ans+=sum[p][j-1]*mll(2).pow(N-j); } } pt(ans); }