#include <bits/stdc++.h>
using namespace std;
#define int long long
const int mod=1e9+7;
signed main(){
    int n;
    string s,t;
    cin>>n>>s>>t;
    int ans=0;
    vector<int>s1;
    for(int i=n-1;i>=0;i--)
        if(s[i]=='1')
            s1.push_back(-i);
    for(int i=0;i<n;i++){
        if(s[i]==t[i])
            continue;
        int pos=lower_bound(s1.begin(),s1.end(),-i)-s1.begin()-1;
        if(pos==-1){
            cout<<-1<<endl;
            return 0;
        }
        ans+=-i-s1[pos];
        s[-s1[pos]]='0'+'1'-s[-s1[pos]];
        s1[pos]=-i;
    }
    cout<<ans<<endl;
}
#include <bits/stdc++.h>
// #include <atcoder/all>
// #include "icld.cpp"
using namespace std;
using ll = long long int;
using vi = vector<int>;
using si = set<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using ss = string;
using db = double;
template<typename T> using minpq = priority_queue <T,vector<T>,greater<T>>;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
#define V vector
#define P pair<int,int>
#define rep(i,s,n) for(int i=(s);i<(int)(n);i++)
#define rev(i,s,n) for(int i=(s);i>=(int)(n);i--)
#define reciv(v,n) vi (v)((n)); rep(i,0,(n))cin>>v[i]
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define ci(x) cin >> x
#define cii(x) ll x;cin >> x
#define cci(x,y) ll x,y;cin >> x >> y
#define co(x) cout << x << endl
#define pb push_back
#define eb emplace_back
#define rz resize
#define pu push
#define sz(x) int(x.size())
#define vij v[i][j]
// ll p = 1e9+7;
// ll p = 998244353;
#define yn cout<<"Yes"<<endl;else cout<<"No"<<endl
#define YN cout<<"YES"<<endl;else cout<<"NO"<<endl
template<class T>void chmax(T &x,T y){x=max(x,y);}
template<class T>void chmin(T &x,T y){x=min(x,y);}

int main(){
  cii(n);
  cci(x0,y0);
  cci(x2,y2);

  db pi=acos(-1);
  db S=pi/n*2;

  db sinS=sin(S);
  db cosS=cos(S);

// co(sinS);co(cosS);
  db hx=1.*(x0+x2)/2;
  db hy=1.*(y0+y2)/2;
// co(hx);co(hy);

  db xd=x0-hx;
  db yd=y0-hy;

  db x,y;
  x= xd*cosS - yd*sinS +hx;
  y= xd*sinS + yd*cosS +hy;
  
  // x=xd*sinS-yd*cosS+hx;
  // y=xd*cosS+yd*sinS+hy;
  
  printf("%.9lf %.9lf\n",x,y);
}