#include<bits/stdc++.h>
#define int long long
using namespace std;
int n;
int fib[10000000];
queue<int> st;
void solve(int n,int top)
{
    if(!n)
        return;
    else
    {
        while(n<fib[top])
            top--;
        st.push(top);
        solve(n-fib[top],top);
    }
}
signed main()
{
    cin>>n;
    fib[1] = 1;
    int i = 1;
    while(fib[i] < n)
    {
        i++;
        fib[i] = fib[i-1]+fib[i-2];
    }
    solve(n,i);
    queue<int> ans;
    int top = st.front();
    st.pop();
    ans.push(1);
    int ans_at = 0;
    while(st.size())
    {
        i = st.front();
        while(top>i)
            ans.push(2),top--,ans_at ^= 1;
        ans.push(1);
        st.pop();
    }
    while(top>1)
       ans.push(2),top--,ans_at ^= 1;
    cout<<ans.size()<<endl;
    int now_at = ans_at^1;
    while(!ans.empty())
    {
        if(ans.front()==1)
        {
            cout<<2-now_at<<endl;
        }
        else
        {
            cout<<3+now_at<<endl;
            now_at ^=1;
        }
        ans.pop();
    }
}


#include "bits/stdc++.h"

using namespace std;

#define ll long long
#define ld long double

#define f first
#define s second
#define pb push_back

#define all(x) x.begin(), x.end()
#define mp(x, y) make_pair(x, y)
#define sz(li) (int) (li).size()
#define sum(a) (accumulate ((a).begin(), (a).end(), 0ll))
#define mine(a) (*min_element((a).begin(), (a).end()))
#define maxe(a) (*max_element((a).begin(), (a).end()))
#define mini(a) (min_element((a).begin(), (a).end()) - (a).begin())
#define maxi(a) (max_element((a).begin(), (a).end()) - (a).begin())
#define lowb(a, x) (lower_bound((a).begin(), (a).end(), (x)) - (a).begin())
#define uppb(a, x) (upper_bound((a).begin(), (a).end(), (x)) - (a).begin())

#define vi vector<int>
#define vl vector<ll>
#define vvi vector<vi>
#define vvl vector<vl>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vpii vector<pii>
#define vpll vector<pll>

#define endl '\n'

#define rep(i, a, b) for(int i = (a); i < (b); i++)

template<typename A> ostream& operator<<(ostream &cout, vector<A> const &v);
template<typename A, typename B> ostream& operator<<(ostream &cout, pair<A, B> const &p) { return cout << "(" << p.f << ", " << p.s << ")"; }
template<typename A> ostream& operator<<(ostream &cout, vector<A> const &v) { cout << "[ "; for(int i = 0; i < v.size(); i++) {if (i) cout << ", "; cout << v[i];} return cout << " ]"; }
template<typename A> ostream& operator<<(ostream &cout, vector<vector<A>> const &v) { cout << "["; for (int i = 0; i < v.size(); i++) { if (i) { cout << " "; } cout << v[i]; if (i < v.size() - 1) { cout << endl; } } return cout << "]"; }
template<typename A, typename B> istream& operator>>(istream& cin, pair<A, B> &p) { cin >> p.first; return cin >> p.second; }
template<typename T, typename U> void cmin(T& a, U b){ if (a > b) a = b; }
template<typename T, typename U> void cmax(T& a, U b){ if (a < b) a = b; }

const int MX = 5e5 + 55;

void solve() {
  int n; cin >> n;
  bitset<MX> s, t; cin >> s >> t;

  if (s.count() != t.count()) {
    cout << -1 << endl;
  } else {
    deque<int> zero;

    int ans = 0;
    for (int i = 0; i < n; i++) {
      if (s[i] == 0) zero.push_back(i);
    }

    for (int i = 0; i < n; i++) {
      if (t[i] == 0) {
        ans += i != zero.front();
        zero.pop_front();
      }
    }

    cout << ans << endl;
  }
}

int main() {
  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

  int t = 1;
  // cin >> t;

  while (t--) {
    solve();
  }

  cerr << "Time: " << 1000.0*clock()/CLOCKS_PER_SEC << " ms\n";
}