#include <iostream>
#include <cassert>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
  long long n;
  cin >> n;
  long long x = 0, y = 0;
  vector<int> Q;
  auto q = [&](int i){
    if(i == 0){
      x += 1;
    }
    if(i == 1){
      y += 1;
    }
    if(i == 2){
      x += y;
    }
    if(i == 3){
      y += x;
    }
    Q.emplace_back(i);
  };
  vector<long long> F(2,0);
  F[1] = 1;
  for(int i = 2; i < 130; ++i){
    long long t = F[i-1] + F[i-2];
    if(t > n) break;
    F.emplace_back(t);
  }
  vector<int> A;
  long long n_ = n;
  for(int i = F.size()-1; i >= 0; --i){
    if(F[i] <= n_){
      A.emplace_back(i);
      n_ -= F[i];
    }
  }
  q(0);
  int p = 3, j = A[0]-1;
  for(auto a : A){
    if(a == A[0]) continue;
    while(j > a){
      q(p);
      p ^= 1;
      --j;
    }
    q(p&1);
  }
  if(y == n){
    swap(x,y);
    for(auto& q : Q)
      q ^= 1;
  }
  cout << Q.size() << endl;
  for(auto e : Q){
    cout << e+1 << '\n';
  }
  cerr << x << " " << y << endl;
  assert(x == n);
}

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>
#include <cassert>


using namespace std;
//using namespace atcoder;

#define REP(i, n) for (int i=0; i<(n); ++i)
#define RREP(i, n) for (int i=(int)(n)-1; i>=0; --i)
#define FOR(i, a, n) for (int i=(a); i<(n); ++i)
#define RFOR(i, a, n) for (int i=(int)(n)-1; i>=(a); --i)

#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<<endl;

template<class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "[";
    REP(i, SZ(v)) {
        if (i) os << ", ";
        os << v[i];
    }
    return os << "]";
}

template<class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    return os << "(" << p.first << " " << p.second << ")";
}

template<class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vvll = vector<vll>;

const ll MOD = 1e9 + 7;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;
const ld eps = 1e-9;


// edit

void solve() {
    int N;
    cin >> N;
    vector<int> A(N), B(N);
    REP(i, N) {
        cin >> A[i];
    }
    REP(i, N) {
        cin >> B[i];
    }

    int diff = *min_element(ALL(B)) - *max_element(ALL(A));
    if (diff < 0) {
        cout << 0 << endl;
    } else {
        cout << diff + 1 << endl;
    }
}


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
//    std::ifstream in("input.txt");
//    std::cin.rdbuf(in.rdbuf());

    solve();


    return 0;
}
