#include<bits/stdc++.h>
using namespace std;
int yt= 1 ; //test variable
bool qf= false ; //fast io enabled/disabled
#define read freopen("in.txt","r",stdin)
#define write freopen("out.txt","w",stdout)
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);qf=true;
#define sc scanf
#define pr printf
#define whi while
#define ll long long
#define ull unsigned long long
#define lld I64d
#define mp make_pair
#define ff first
#define ss second
#define vc vector
#define pb push_back
#define ite iterator
#define str string
#define bl bool
#define tr true
#define fl false
#define endl '\n'
#define ret return
#define rsort greater<int>()
#define nl if(qf==tr) pr("\n");else cout<<"\n";
#define test if(qf==tr) pr("TEST %d\n",yt++);else cout<<"TEST "<<yt++<<"\n";
#define gcd(a,b) __gcd(a,b)
#define mod 1000000007
#define all(c) c.begin(),c.end()
#define sz(c) c.size()
#define clr(c) c.clear()
#define fd(c,a) c.find(a)
#define bg(c) c.begin()
#define ed(c) c.end()
#define ins(c,a) c.insert(a)
#define rem(c,a) c.erase(a)
#define si(n) if(qf==fl) sc("%d",&n); else cin>>n;
#define sll(n) if(qf==fl) sc("%lld",&n); else cin>>n;
#define pi(n) if(qf==fl) pr("%d ",n); else cout<<n<<" ";
#define pll(n) if(qf==fl) pr("%lld ",n); else cout<<n<<" ";
#define tc int t;if(qf==fl) si(t) else cin>>t;whi(t--)
#define ct continue
#define debug system("PAUSE");
class Quacking
{
public :
int quack( string a)
{
int i,j,l,ans= 0 ,lastpos;
str quack= "quack" ,b;
whi( 1 )
{
bl found= fl;
l= sz( a) ;
b= "" ;
lastpos= - 1 ;
for ( i= 0 ,j= 0 ; i< l; i++ )
{
if ( j< 5 and a[ i] == quack[ j] ) j++ ;
else if ( j== 5 )
{
found= tr;
lastpos= i;
j= 0 ;
i-- ;
}
else if ( a[ i] ! = quack[ j] )
{
if ( lastpos== - 1 ) lastpos= i;
b+ = a[ i] ;
}
}
if ( j== 5 ) found= tr;
else if ( j! = 0 )
{
if ( lastpos== - 1 ) lastpos++ ;
for ( i= lastpos; i< l; i++ ) b+ = a[ i] ;
}
cout << b<< endl;
a= b;
if ( found== fl)
{
if ( ans== 0 ) ans= - 1 ;
break ;
}
ans++ ;
}
if ( a! = "" ) ret - 1 ;
ret ans;
}
} ;
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKaW50IHl0PTE7ICAgICAgICAgICAvL3Rlc3QgdmFyaWFibGUKYm9vbCBxZj1mYWxzZTsgICAgICAvL2Zhc3QgaW8gZW5hYmxlZC9kaXNhYmxlZAoKI2RlZmluZSByZWFkICAgICAgICBmcmVvcGVuKCJpbi50eHQiLCJyIixzdGRpbikKI2RlZmluZSB3cml0ZSAgICAgICBmcmVvcGVuKCJvdXQudHh0IiwidyIsc3Rkb3V0KQojZGVmaW5lIGZhc3QgICAgICAgIGlvc19iYXNlOjpzeW5jX3dpdGhfc3RkaW8oZmFsc2UpO2Npbi50aWUoMCk7Y291dC50aWUoMCk7cWY9dHJ1ZTsKCiNkZWZpbmUgc2MgICAgICAgICAgc2NhbmYKI2RlZmluZSBwciAgICAgICAgICBwcmludGYKI2RlZmluZSB3aGkgICAgICAgICB3aGlsZQojZGVmaW5lIGxsICAgICAgICAgIGxvbmcgbG9uZwojZGVmaW5lIHVsbCAgICAgICAgIHVuc2lnbmVkIGxvbmcgbG9uZwojZGVmaW5lIGxsZCAgICAgICAgIEk2NGQKI2RlZmluZSBtcCAgICAgICAgICBtYWtlX3BhaXIKI2RlZmluZSBmZiAgICAgICAgICBmaXJzdAojZGVmaW5lIHNzICAgICAgICAgIHNlY29uZAojZGVmaW5lIHZjICAgICAgICAgIHZlY3RvcgojZGVmaW5lIHBiICAgICAgICAgIHB1c2hfYmFjawojZGVmaW5lIGl0ZSAgICAgICAgIGl0ZXJhdG9yCiNkZWZpbmUgc3RyICAgICAgICAgc3RyaW5nCiNkZWZpbmUgYmwgICAgICAgICAgYm9vbAojZGVmaW5lIHRyICAgICAgICAgIHRydWUKI2RlZmluZSBmbCAgICAgICAg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kodCkgZWxzZSBjaW4+PnQ7d2hpKHQtLSkKI2RlZmluZSBjdCAgICAgICAgICBjb250aW51ZQojZGVmaW5lIGRlYnVnICAgICAgIHN5c3RlbSgiUEFVU0UiKTsKCmNsYXNzIFF1YWNraW5nCnsKcHVibGljOgogICAgaW50IHF1YWNrKHN0cmluZyBhKQogICAgewogICAgICAgIGludCBpLGosbCxhbnM9MCxsYXN0cG9zOwogICAgICAgIHN0ciBxdWFjaz0icXVhY2siLGI7CiAgICAgICAgd2hpKDEpCiAgICAgICAgewogICAgICAgICAgICBibCBmb3VuZD1mbDsKICAgICAgICAgICAgbD1zeihhKTsKICAgICAgICAgICAgYj0iIjsKICAgICAgICAgICAgbGFzdHBvcz0tMTsKICAgICAgICAgICAgZm9yKGk9MCxqPTA7aTxsO2krKykKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgaWYoajw1IGFuZCBhW2ldPT1xdWFja1tqXSkgaisrOwogICAgICAgICAgICAgICAgZWxzZSBpZihqPT01KQogICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgIGZvdW5kPXRyOwogICAgICAgICAgICAgICAgICAgIGxhc3Rwb3M9aTsKICAgICAgICAgICAgICAgICAgICBqPTA7CiAgICAgICAgICAgICAgICAgICAgaS0tOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZWxzZSBpZihhW2ldIT1xdWFja1tqXSkKICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICBpZihsYXN0cG9zPT0tMSkgbGFzdHBvcz1pOwogICAgICAgICAgICAgICAgICAgIGIrPWFbaV07CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICAgICAgaWYoaj09NSkgZm91bmQ9dHI7CiAgICAgICAgICAgIGVsc2UgaWYoaiE9MCkKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgaWYobGFzdHBvcz09LTEpIGxhc3Rwb3MrKzsKICAgICAgICAgICAgICAgIGZvcihpPWxhc3Rwb3M7aTxsO2krKykgYis9YVtpXTsKICAgICAgICAgICAgfQogICAgICAgICAgICBjb3V0PDxiPDxlbmRsOwogICAgICAgICAgICBhPWI7CiAgICAgICAgICAgIGlmKGZvdW5kPT1mbCkKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgaWYoYW5zPT0wKSBhbnM9LTE7CiAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgfQogICAgICAgICAgICBhbnMrKzsKICAgICAgICB9CiAgICAgICAgaWYoYSE9IiIpIHJldCAtMTsKICAgICAgICByZXQgYW5zOwogICAgfQp9Ow==