import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class Main {
static int p1 = 0;
static int p2 = -1;
static int p3 = -1;
static int u;
static int[] fBefP = new int[26];
static int[] ftot = new int[26];
static int ans = 0;
static int tempU = 0;
static int tempUBeforeP2 = 0;
public static void main
(String[] args
){ MyScanner sc = new MyScanner();
s = sc.nextLine();
boolean[] a = new boolean[26];
int U = 0;
for(int i = 0;i<s.length();i++){
int c = cal(s.charAt(i));
if(a[c]==false){
U++;
a[c]= true;
}
}
int n=1;
char c = s.charAt(0);
for(int i = 1;i<s.length();i++){
if(s.charAt(i)==c){
n++;
}
else{
ans += n*(n+1)/2;
n = 1;
c = s.charAt(i);
}
}
ans += n*(n+1)/2;
for(u=2;u<=U;u++){
p1 = 0;
p2 = -1;
p3 = -1;
tempU= 0;
ans = 0;
ftot = new int[26];
fBefP = new int[26];
tempUBeforeP2 = 0;
while(tempU<u){
p2++;
if(p2==s.length())
break;
int cp2 = cal(s.charAt(p2));
if(ftot[cp2]==0){
tempU++;
tempUBeforeP2++;
}
fBefP[cp2]++;
ftot[cp2]++;
}
p3 = p2;
while(tempU==u){
p3++;
if(p3==s.length()){
tempU++;
break;
}
int cp3 = cal(s.charAt(p3));
if(ftot[cp3]==0){
tempU++;
}
ftot[cp3]++;
}
boolean ch1 = addSubs();
boolean w = true;
while(w){
if(ch1){
while(movP2()){
boolean check = addSubs();
if(check==false){
break;
}
}
}
w = movP3();
ch1 = true;
}
}
}
public static boolean addSubs(){
while(tempU>u && tempUBeforeP2==u){
ans += p3-p2;
int cp1 = cal(s.charAt(p1));
if(fBefP[cp1]==1){
tempUBeforeP2--;
}
if(ftot[cp1]==1){
tempU--;
}
fBefP[cp1]--;
ftot[cp1]--;
p1++;
}
if(tempU==u){
return false;
}
else{
return true;
}
}
public static boolean movP2(){
int req = 0;
while(req<1){
p2++;
int cp2 =cal(s.charAt(p2));
if(fBefP[cp2]==0){
req++;
tempUBeforeP2++;
}
fBefP[cp2]++;
if(p2>=p3-1 && req<1)
return false;
}
return true;
}
public static boolean movP3(){
if(p3==s.length())
return false;
else{
while(tempU==u){
p3++;
if(p3==s.length()){
tempU++;
break;
}
int cp3 = cal(s.charAt(p3));
if(ftot[cp3]==0){
tempU++;
}
ftot[cp3]++;
}
return true;
}
}
public static int cal(char c){
return ((int)c-97);
}
}
class MyScanner {
public MyScanner() {
}
while (st == null || !st.hasMoreElements()) {
try {
e.printStackTrace();
}
}
return st.nextToken();
}
int nextInt() {
}
long nextLong() {
return Long.
parseLong(next
()); }
double nextDouble() {
return Double.
parseDouble(next
()); }
try {
str = br.readLine();
e.printStackTrace();
}
return str;
}
}