#include <functional>
#include <stdexcept>
#include <streambuf>
#include <exception>
#include <algorithm>
#include <iostream>
#include <iterator>
#include <typeinfo>
#include <utility>
#include <complex>
#include <numeric>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <sstream>
#include <cassert>
#include <iomanip>
#include <cstring>
#include <locale>
#include <memory>
#include <iosfwd>
#include <string>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <list>
#include <map>
#include <ios>
#include <new>
#include <set>
 
#define int long long
#define ll long long 
#define F first
//#define endl "\n"
#define S second
#define make make_pair
#define pb push_back
#define sz(x) (ll)(x.size()) 
#define all(x) x.begin (), x.end ()

using namespace std;

typedef long double ld;

const int P = 997;
const int MOD = (int)1e9 + 7;
const int N = (int)1e5 * 3 + 22 ;
const ll INF = (ll)1e18;
const double eps = (double)1e-6;

string s;
int h[N], h1[N], p[N];

bool check (int x, int pos, int pos1) {
    if (pos - x < 0 || x + pos1 > sz(s) - 1) return 0;
    int l, r;
    l = pos - x; r = pos1 + x;
    int cost1 = (h[r] - ((h[l - 1] * p[r - l + 1]) % MOD) + MOD) % MOD;
    l = sz(s) - 1 - (pos1 + x); r = sz(s) - 1 - (pos - x);
    int cost2 = (h1[r] - ((h1[l - 1] * p[r - l + 1]) % MOD) + MOD) % MOD;
    if (cost1 == cost2) return 1;
    else return 0; 
}
int sum[2][3000], a[N];

void solve () {
    cin >> s;
    for (int i = 0; i < sz(s); ++i) {
        a[i] = s[i] - 'A' + 1;
    }
    int ans = 0;
    for (int i = 0; i < sz(s); ++i) {
        if (i % 2 == 0){
            ans += sum[0][a[i]] + sum[1][a[i]];
            sum[0][a[i]] ++;
        }
        if (i % 2 == 1) {
            ans += sum[1][a[i]] + sum[0][a[i]];
            sum[1][a[i]]++;
        }
    }
    
    cout << (sz(s) + 1) * sz(s) / 2 - ans - sz(s) + 1;
}

signed main () {
    #ifdef Maga
        freopen("input.txt", "r", stdin);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int t = 1;
    while (t --) {
        solve ();
    }
    return 0;
}

