#include<bits/stdc++.h>							
#define pb push_back
#define ll long long
#define ld long double
#define mod 1000000007ll
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);cout.precision(25);
using namespace std;

ll gcd(ll a, ll b) {if(a == 0) return b; return gcd(b % a, a);}
ll lcm(ll a, ll b) {return (a * b) / gcd(a, b);}
ll find_pow(ll a, ll b) {ll res = 1;while(b) {if(b & 1) res *= a;a *= a;b >>= 1;}return res;}
ll find_powmod(ll a, ll b) {ll res = 1; while(b) {if(b&1) (res *= a)%= mod; (a *= a)%=mod; b >>= 1;}return res%mod;}
ll invMod(ll n, ll y = mod){return find_pow(n, y-2);}

clock_t time_p=clock();
void Time(){time_p=clock()-time_p;cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";}


	
	
void solve() {
	string s;
	cin >> s;
	int n = s.length(), ans = -1;
	string t = "atcoder";
	for(int i = 0; i < n; ++i) {
		if(s[i] != 'a') {
			ans = i;
			break;
			}
		}
		if(ans == 0) cout << 0 << endl;
		else if(s > t) cout << 0 << endl;
		else if(ans == -1) cout << -1 << endl;
		else if(s[ans] > 't') cout << ans - 1 << endl;
		else cout << ans << endl;
		return;
	}

int main() {
	fastio();
	int t;	
	cin >> t;
	while(t--)
	solve();
	
	Time();
	return 0;
}
	

#include <bits/stdc++.h>
using namespace std;
#define int long long

// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds; 
  
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 


#define pf push_front
#define pb push_back
#define FOR(i,l,r) for(int i=l;i<r;i++)
#define ROF(i,r,l) for(int i=r;i>=l;i--)
#define all(v) (v).begin(),(v).end()
#define ff first
#define ss second
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pair<int,int>> vpi;
typedef vector<vi> vvi;

const int M = 1e9+7;
const int N = 2e5;
int po(int,int);
int n;
bool check(int x){
    return ((n/x - x + 1)%2==0);
}

void solve(){
    cin>>n;
    n = 2*n;
    int ans = 0;
    for(int i=1;i*i<=n;i++){
        if(n%i==0){
            if(check(i)) ans++;
            if(check(n/i)) ans++;
        }
    }
    cout<<ans<<"\n";

}




int32_t main() {
   
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);cout.tie(NULL);
    
   #ifndef ONLINE_JUDGE 
   freopen("input.txt", "r", stdin);  
   freopen("output.txt", "w", stdout); 
   #endif 

    int t=1;
    // cin>>t;
    FOR(i,1,t+1){
        //cout<<"Case #"<<i<<": "; 
        solve();
        
    }
    
    return 0;
    
    
}


int po(int a,int b){
    if(b==0) return 1;
    int ans=1;
    if(b%2==0){
        ans = po(a,b/2)%M;
        ans=(ans%M * ans%M)%M;
    }
    else{
        ans = po(a,(b-1)/2)%M;
        ans = (ans%M * ans%M * a)%M;
    }
    return ans%M;
}

