// Problem: B - Hydrate
// Contest: AtCoder - AtCoder Beginner Contest 207
// URL: https://atcoder.jp/contests/abc207/tasks/abc207_b
// Memory Limit: 1024 MB
// Time Limit: 2000 ms
// 
// Powered by CP Editor (https://cpeditor.org)

//The code written by Javokhir Akramjonov

#include <bits/stdc++.h>

using namespace std;

//#define file
#define int long long
#define ff first
#define ss second
#define N 111111
#define pb push_back
#define eb emplace__back
#define pii pair<int, int>
#define vi vector<int>
#define rep(i, a, b) for(int i = a; i < b; i ++)
#define trav(x, a) for(auto &x : a)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).end()
#define ios ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const int M = 1e9 + 7;

void solution()
{
    /*a + bx <= dcx
    x >= a / (dc-b);*/
    int a, b, c, d;
    cin >> a >> b >> c >> d;
	if(d * c > b)
	{
		if(a % (d * c - b) == 0)
			cout << a / (d * c - b);
		else
			cout << a / (d * c - b) + 1;
	}
	else if(d * c == b)
	{
		if(a > 0)
			cout << -1;
		else
			cout << 0;
	}
	else
	{
		if(a == 0)
			cout << 0;
		else
			cout << -1;
	}
}

signed main()
{
	#ifdef file
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
    ios;
    int t = 1;
	//cin >> t;
    while(t--)
        solution();
    return 0;
}

#include<bits/stdc++.h>

using namespace std;

#define LL long long
#define DD double
#define Pb push_back
#define Bp pop_back
#define Pf push_front
#define Fp pop_front
#define Ub upper_bound
#define Lb lower_bound
#define Bs binary_search
#define In insert
#define Mp make_pair
#define All(x) x.begin(), x.end()
#define mem(a, b) memset(a, b, sizeof(a))
#define fast ios_base::sync_with_stdio(0);cin.tie(0)
#define X first
#define Y second

const int mx1 = 65;
const int mx2 = 205;
const int mx3 = 2005;
const int mx4 = 30005;
const int mx5 = 100005;
const int mx6 = 1000005;

typedef vector<int> Vi;
typedef vector<DD> Vd;
typedef vector<bool> Vb;
typedef vector<Vi> VVi;
typedef pair<int, int> Pii;
typedef pair<DD, DD> Pdd;
typedef vector<Pii> Vpi;
typedef vector<Pdd> Vpd;
typedef queue<int> Qi;
typedef stack<int> Si;
typedef deque<int> Di;

int _toggle(int N, int pos) {return N = N ^ (1 << pos);}
int _set(int N, int pos) {return N = N | (1 << pos);}
int _reset(int N, int pos) {return N = N & ~(1 << pos);}
bool _check(int N, int pos) {return (bool)(N & (1 << pos));}
bool _upper(char a) {return a >= 'A' && a <= 'Z';}
bool _lower(char a) {return a >= 'a' && a <= 'z';}
bool _digit(char a) {return a >= '0' && a <= '9';}

int dx[] = {1, -1, 0, 0, -1, -1, 1, 1};
int dy[] = {0, 0, 1, -1, -1, 1, -1, 1};

///******************************************************///

int n;
string s, t;
set<int> st;

void solve()
{
    cin >> n >> s >> t;
    for(int i = 0; i < n; i++){
        if(s[i] == '1'){
            st.In(i);
        }
    }
    LL ans = 0;
    for(int i = 0; i < n; i++){
        if(s[i] == '1' && t[i] == '0'){
            st.erase(i);
            auto j = st.Lb(i);
            if(j == st.end()){
                cout << -1 << '\n';
                return;
            }
            ans += (*j - i);
            s[*j] = '0';
            st.erase(j);
        }
        if(s[i] == '0' && t[i] == '1'){
            auto j = st.Lb(i);
            if(j == st.end()){
                cout << -1 << '\n';
                return;
            }
            ans += (*j - i);
            s[*j] = '0';
            st.erase(j);
        }
    }
    cout << ans << '\n';
}

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    fast;
    int tc = 1;
    //cin >> tc;
    while(tc--){
        solve();
    }
}
