#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int U;
template <typename T>
inline void read(T &x)
{
	x = 0;bool b = 0;char c;
	for (c = getchar();!isdigit(c);b |= (c == '-'), c = getchar());
	for (;isdigit(c);x = (x << 1) + (x << 3) + (c ^ 48), c = getchar());
	if (b) x = -x;
}
template <typename T>
inline void write(T x, int base = 10)
{
	if (x == 0)
	{
	    putchar('0');
	    return ;
	}
	if (x < 0) putchar('-'), x = -x;
	static int stk[70];
	int top = 0;
	while (x)
	{
		stk[top++] = x % base;
		x /= base;
	}
	while (top > 0)
	{
		putchar(stk[--top] ^ 48);
	}
}
const int M = 1000005;
int num, mu[M + 5], ol[M + 5], prime[M + 3];
int l, r;
void get()
{
	mu[1] = 1;
	for (int i = 2;i <= M;++i)
	{
		if (!ol[i])
			prime[++num] = i, mu[i] = -1;
		for (int j = 1;j <= num && i * prime[j] <= M;++j)
		{
			ol[i*prime[j]] = 1;
			if (i % prime[j] == 0)
			{
				mu[i * prime[j]] = 0;
				break;
			}
			mu[i * prime[j]] = -mu[i];
		}
	}
}
ll tmp(int t)
{
	return (ll)t * (t-1);
}
ll ans;
int main()
{
	get();
	read(l);read(r);
	for (int i = 2;i <= r;++i)
		ans -= tmp(r / i - (l - 1) / i) * mu[i];
	for (int i = l;i <= r;++i)
		ans -= ((r / i - 1) << 1);
	if (l == 1)
		ans += (r - 1) * 2;
	write(ans);
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
const int maxn=222222,mod=998244353;
#define MP make_pair
#define PB push_back
#define lson o<<1,l,mid
#define rson o<<1|1,mid+1,r
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define ROF(i,a,b) for(int i=(a);i>=(b);i--)
#define MEM(x,v) memset(x,v,sizeof(x))
inline ll read(){
	char ch=getchar();ll x=0,f=0;
	while(ch<'0' || ch>'9') f|=ch=='-',ch=getchar();
	while(ch>='0' && ch<='9') x=x*10+ch-'0',ch=getchar();
	return f?-x:x;
}
char s[maxn];
int n,cnt[26];
ll ans;
int main(){
	scanf("%s",s+1);
	n=strlen(s+1);
	cnt[s[n]-'a']++;
	ROF(i,n-1,1){
		cnt[s[i]-'a']++;
		if(s[i]==s[i+1]){
//			printf("at %d\n",i);
			FOR(j,0,25) if(j!=s[i]-'a') ans+=cnt[j],cnt[s[i]-'a']+=cnt[j],cnt[j]=0;
//			printf("ans=%d\n",ans);
		}
	}
	printf("%lld\n",ans);
}
/*
azaazbbzzaaza
*/