#include <bits/stdc++.h>
namespace predefined {
constexpr bool kIsDebug = false;
enum class LogType { INFO, DEBUG };
template <LogType Type, bool... Bools>
struct Log;
template <>
struct Log<LogType::INFO> {
  Log() {}
  ~Log() { std::cout << '\n'; }
  template <typename T>
  Log &operator<<(const T &t) {
    std::cout << t;
    return *this;
  }
};
template <>
struct Log<LogType::DEBUG, true> {
  Log() {}
  ~Log() { std::cout << '\n'; }
  void Open() { freopen("input.txt", "r", stdin); }
  template <typename T>
  Log &operator<<(const T &t) {
    std::cout << t;
    return *this;
  }
};
template <>
struct Log<LogType::DEBUG, false> {
  Log() {}
  ~Log() {}
  void Open() {}
  template <typename T>
  Log &operator<<(const T &t) {
    return *this;
  }
};
namespace solver {
using SolveFunc = std::function<void()>;
template <typename MultiRunner>
void Run(SolveFunc solve_func);
template <>
void Run<std::true_type>(SolveFunc solve_func) {
  int test_case;
  std::cin >> test_case;
  while (test_case--) {
    solve_func();
  }
}
template <>
void Run<std::false_type>(SolveFunc solve_func) {
  solve_func();
}
}  // namespace solver
template <bool MultiTest>
struct Solver {
  constexpr static bool condition = MultiTest | kIsDebug;
  typedef typename std::conditional<condition, std::true_type,
                                    std::false_type>::type run_type;
  explicit Solver(solver::SolveFunc solve_func) {
    solver::Run<run_type>(solve_func);
  }
};
template <typename T>
struct BoolMap {
  explicit BoolMap(const T &_true_value, const T &_false_value)
      : true_value(_true_value), false_value(_false_value) {}
  const T true_value;
  const T false_value;
  const T inline GetValue(const bool bool_key) const {
    return bool_key ? true_value : false_value;
  };
};
}  // namespace predefined
namespace {
using namespace std;
constexpr bool kMultiTestCase = false;
using Solver = predefined::Solver<kMultiTestCase>;
}  // namespace
void solve() {
  int n;
  string s, t;
  cin >> n >> s >> t;
  int s_count = 0, t_count = 0;
  int zero_first = 0, one_first = 0;
  for (int i = 0; i < n; ++i) {
    if (s[i] == '0') ++s_count;
    if (t[i] == '0') ++t_count;
    if (s[i] != t[i]) {
      if (s[i] == '0') {
        ++zero_first;
        one_first -= (one_first != 0);
      } else {
        ++one_first;
        zero_first -= (zero_first != 0);
      }
    }
  }
  if (s_count != t_count) {
    predefined::Log<predefined::LogType::INFO>() << -1;
    return;
  }
  predefined::Log<predefined::LogType::INFO>() << zero_first + one_first;
}
int main(int argc, char **argv) {
  std::ios::sync_with_stdio(false);
  std::cin.tie(NULL);
  predefined::Log<predefined::LogType::DEBUG, predefined::kIsDebug>().Open();
  ;
  Solver(std::bind(solve));
  return 0;
}
