#include<bits/stdc++.h> using namespace std; int n,c=-1,sum,ok=1; char ch[8001]; int main(){ scanf("%d%s",&n,ch); int j=n-1; for(int i=0;i<=j-1;i++){ for(int k=j;k>=i;k--){ if(k==i){ if(n%2==0||c!=-1){ ok=0; break; } c=1; sum+=n/2-i; break; } if(ch[k]==ch[i]){ for(int t=k;t<=j-1;t++){ ch[t]=ch[t+1]; } sum+=j-k; j--; break; } } if(!ok) break; } if(!ok) printf("Impossible"); else cout<<sum; return 0; } /************************************************************** Problem: 1842 User: chenpengxi Language: C++ Result: Accepted Time:54 ms Memory:2084 kb ****************************************************************/