/*
Author: Zcus
Blog: https://cnblogs.com/zcus
*/

#include <bits/stdc++.h>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define pii pair<int, int>
#define mp make_pair
#define debug(x) cout << #x << " = " << x << endl
#define For(i, x, y) for (int i = x; i <= y; i++) 
#define Rep(i, x, y) for (int i = x; i >= y; i--) 
#define file(FILE_NAME) freopen(FILE_NAME".in", "r", stdin), freopen(FILE_NAME".out", "w", stdout)
#define filein(FILE_NAME) freopen(FILE_NAME".in", "r", stdin);
#define fileout(FILE_NAME) freopen(FILE_NAME".out", "w", stdout);

template<class T> inline bool Chkmax(T& x, const T& y) { return x < y ? x = y, true : false; }
template<class T> inline bool Chkmin(T& x, const T& y) { return x > y ? x = y, true : false; }

#define I int
inline I ri() {
	I s = 0, w = 1;
	char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') w = -1; c = getchar();}
	while (c >= '0' && c <= '9') { s = (s << 1) + (s << 3) + (c ^ 48); c = getchar();}
	return s * w;
}
#undef I


#define int long long

const int maxn = 2e5 + 50;
int k;


int tong[maxn];


int calc(int k) {
	int res = 0;
	for (int l = 1, r; l <= k; l = r + 1) {
		r = k / (k / l);
		res = res + (k / l) * (r - l + 1);
	}
	return res;
}
signed main() {

	cin >> k;

	int ans = 0;
	for (int i = 1; i <= k; i++) {
		ans += calc(k / i);
	}

	cout << ans << endl;
	return 0;
}

#include <bits/stdc++.h>
using namespace std;

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define FastIO()            ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define read()              freopen("in.txt","r",stdin)
#define write()             freopen("out.txt","w",stdout)

typedef long long           ll;
typedef unsigned long long  ull;
typedef double              dbl;
typedef float               flt;

typedef pair<int, int>      pii;
typedef pair<ll, ll>        pl;

typedef vector<int>         vi;
typedef vector<ll>          vl;
typedef vector<pii>         vpii;
typedef vector<pl>          vpl;

#define pie                 acos(-1)

#define mp                  make_pair
#define pb                  push_back
#define eb                  emplace_back
#define ff                  first
#define ss                  second

#define MAX                 300005
#define MOD                 1000000007
#define INF                 1000000100

#define for0(i, n)          for(ll i=0; i<n; i++)
#define for1(i, n)          for(ll i=1; i<=n; i++)
#define forab(i, a, b)      for(ll i=a; i<=b; i++)
#define forabx(i, a, b, x)  for(ll i=a; i<=b; i+=x)
#define forinv(i, a, b)     for(ll i=a; i>=b; i--)

#define clr0(a)             memset(a, 0, sizeof(a))
#define ceil(x, y)          (x+y-1) / (y)
#define max3(a, b, c)       max(a, max(b, c))
#define min3(a, b, c)       min(a, min(b, c))
#define gcd(a, b)           __gcd(a, b)
#define lcm(a, b)           ((a * b) / __gcd(a, b))
#define sort1(a, x, y)      sort(a+x, a+y+1)
#define debug(x)            cout << "DEBUG " << x << endl;

#define Y()                 cout << "YES" << endl;
#define N()                 cout << "NO" << endl;
#define inArr(a, x, y)      forab(i, x, y) { cin >> a[i]; }
#define outArr(a, x, y)     forab(i, x, y) { cout << a[i] << " "; } cout << endl;


void solve() {
    ll n;
    cin >> n;
    char a[n+10], b[n+10];
    cin >> a;
    cin >> b;
    vl a0, b0;
    ll ca=0, cb=0;
    for0(i, n) {
        if (a[i]=='0') {
            ca ++;
            a0.pb(i);
        }
        if (b[i]=='0') {
            cb++;
            b0.pb(i);
        }
    }
    ll ans = 0;
    if (ca!=cb) {
        ans = -1;
    }
    else {
        for0(i, ca) {
            if (a0[i]!=b0[i]) {
                ans ++;
            }
        }
    }
    cout << ans << endl;
}

void testcase() {
    ll t;
    cin >> t;
    while (t--) {
        solve();
    }
}

int main () {
    FastIO()

    //testcase();
    solve();

    return 0;
}

