def manachar(s): def get(i): return '^' if i & 1 else s[i>>1] size = len(s) * 2 - 1 rads = [0] * size i = j = 0 while i < size: while i - j >= 0 and i + j < size and get(i - j) == get(i + j): j += 1 rads[i] = j k = 1 while i - k >= 0 and i + k < size and k + rads[i - k] < j: rads[i + k] = rads[i - k] k += 1 i += k j -= k return rads def solve(): s = input() n = len(s) assert 4 <= n <= 5000 assert all('a' <= c <= 'z' for c in s) rads = manachar(s) def is_palindrome(l, r): return rads[l + r] >= r - l + 1 p1 = [] for i in range(n - 3): if is_palindrome(0, i): p1.append(i) p2 = [0] * (n - 1) for i in p1: for j in range(i + 1, n - 2): if is_palindrome(i + 1, j): p2[j] += 1 sum_p2 = [0] * n for i in range(n - 1): sum_p2[i + 1] = sum_p2[i] + p2[i] ans = 0 for k in range(2, n - 1): if is_palindrome(k + 1, n - 1): ans += sum_p2[k] print(ans) if __name__ == '__main__': solve()