#include using namespace std; int main(){ int N; string S; cin>>N>>S; int Q=count(S.begin(),S.end(),'Q'); if(N%Q)return puts("-1"),0; for(int i=0;i