/******************************************************************************
Online C++ Compiler.
Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.
*******************************************************************************/
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int util(string s){
unordered_map<char,int> mp;
mp['a']=1;
mp['b']=1;
mp['c']=2;
mp['d']=2;
mp['e']=2;
mp['f']=3;
mp['g']=3;
mp['h']=3;
mp['i']=4;
mp['j']=4;
mp['k']=4;
mp['l']=5;
mp['m']=5;
mp['n']=5;
mp['o']=6;
mp['p']=6;
mp['q']=6;
mp['r']=7;
mp['s']=7;
mp['t']=7;
mp['u']=8;
mp['v']=8;
mp['w']=8;
mp['x']=9;
mp['y']=9;
mp['z']=9;
int ans = 0;
int n = s.length();
for(int len = 1; len<=n;++len){
int sum = 0;
for(int i=0;i<len;++i){
sum+=mp[s[i]];
}
if(sum%len==0)ans++;
int start = 0;
int end = start+len;
while(end<n){
sum-=mp[s[start]];
sum+=mp[s[end]];
if(sum%len==0)ans++;
start++;
end++;
}
}
return ans;
}
int main()
{
//cout<<"Hello World";
cout<<util("bdh")<<"\n";
cout<<util("abcd");
return 0;
}