#include using namespace std; long long ttt,n,ans,x,k; char a[10010],ch; int main(){ cin>>ttt; while (ttt--){ while ((ch=getchar())>'z'||ch<'a'); for (n=ans=0;ch>='a'&&ch<='z';ch=getchar()) a[++n]=ch; for (x=1;x<=n;x++) for (k=2;x*k*k<=n;k++) if (a[x*k]=='r') if (a[x]=='y'&&a[x*k*k]=='x') ans++; else if (a[x]=='x'&&a[x*k*k]=='y') ans++; cout<