#include <bits/stdc++.h>
using namespace std;

int rfind(const string& s, const char& c) {
	for (int i = s.length() - 1; i >= 0; i--) {
		if (s[i] == c) {
			return s.length() - 1 - i;
		}
	}
	return -1;
}

void idkwhattonamethisshit(vector<string>& vec, int i, int& ans) {
	int l1 = vec[i].length();
	int l2 = vec[i - 1].length();
	char c1 = vec[i][l1];
	char c2 = vec[i - 1][l2 - l1];
	if (l2 < l1) {
		return;
	}
	if (c1 == c2) {
		cout << (int)c1 << endl;
		ans++;
	}
}

int main(int argc, char const *argv[])
{
	string s;
	cin >> s;
	vector<string> vec(2);
	int i = 1;
	int direction = 1;
	for (const char& c : s) {
		int r = rfind(vec[i], c);
		if (r != -1) {
			if (r % 2 == 0) {
				//cout << vec[i] << endl;
				string a = vec[i].substr(vec[i].length() - 1 - r / 2, r + 1);
				vec[i] = vec[i].substr(0, vec[i].length() - r / 2 );
				if (a.length() > 0) {
					a.erase(a.begin());
				}

				//cout << c << " " << a << " " << vec[i] << endl;
				i++;

				direction *= -1;

				a += c;
				vec.push_back(a);

			}
			else {
				vec[i] += c;

			}
		}
		else {
			vec[i] += c;
		}
	}
	int ans = 0;
	for (int j = 1; j < vec.size(); j++) {
		int s1 = vec[j].size();
		int s2 = vec[j - 1].size();

		int mins = min(s1, s2);
		for (int u = 0; u < mins; u++) {
			auto c1 = vec[j][u];
			auto c2 = vec[j - 1][s2 - 1 - u];
			if (c1 == c2) {
				ans++;
			}
		}
	}
	//for (int j = 0; j < vec.size(); j++) {
	//	cout << vec[j] << endl;
	//}
	cout << ans << endl;
	return 0;
}