#include <stdio.h>
#include <string.h>

main()
{
	int N = 3000;
	char T[N];
	scanf("%s", &T);
	int length = strlen(T);
	
	if (length > 2 && length <= 3000)
	{
		int i, j, snake_score;
		
		for (i = 0; i < length-1; i++)
		{
			for (j = i; j < length; j++)
			{
				if (T[i] == T[i+j])
				{
					snake_score++;
				}
			}
		}
		
		printf("%d", snake_score);
	}
}