#include <bits/stdc++.h>
 
#define pb push_back
#define ff first
#define ss second
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
const ll INF = (ll)1<<62;
const ll MOD = 1e9+7;
const int iINF = 1<<30;
const double PI = 3.14159265359;

void solve(){
  ll n;
  cin >> n;

  vector<ll> fib(105, 0);
  fib[0] = fib[1] = 1;
  for(int i=2;i<100;i++)
    fib[i] = fib[i-1]+fib[i-2];

  int s = 0;
  for(int i=1;i<100;i+=2){
    if(fib[i] > n){
      s = i;
      break;
    }  
  }  
  s--;

  vector<int> ans;
  vector<bool> taken(105, false);
  ll m = n;
  for(int i=s;i>=1;i--){
    if(m >= fib[i]){
      taken[i] = true;
      m -= fib[i];
    }  
  }  

  for(int i=s;i>=1;i-=2){
    if(taken[i-1])
      ans.pb(2);
    if(taken[i])
      ans.pb(1);

    ans.pb(4);
    ans.pb(3);
  }  

  cout << ans.size() << "\n";
  for(int x : ans)
    cout << x << "\n";
  
}

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

  int t = 1;
  //cin >> t;
  while(t--){
    solve();
  }  
  
  return 0;
}  

#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
#define int long long int 
#define INF             1e14
#define dd              double
#define MOD             1000000007
#define my_sizeof(type) ((char *)(&type+1)-(char*)(&type)) 
#define nl              cout<<endl
#define fill(a,val)     memset(a,val,sizeof(a))
#define mp              make_pair
#define endl            "\n"
#define pb              push_back
#define ff              first    
#define ss              second
#define SIZE            200005
#define all(v)          v.begin(),v.end()
#define s(ar,n)         sort(ar,ar+n)
#define rs(ar,n)        sort(ar, ar+n, greater<ll>()) 
#define oa(a,n)         for(ll i=0;i<n;i++)cout<<a[i]<<" ";nl
#define ain(a,n)         for(ll i=0;i<n;i++)cin>>a[i];
#define maxa(ar,N)      *max_element(ar,ar+N)
#define mina(ar,N)      *min_element(ar,ar+N)
#define fastio()        ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
// find_by_order() - 0 indexing
// order_of_key() - number of elements strictly smaller
int exp(int a,int b)
{
    int ans=1;
    for(int i =0;i<b;i++)ans*=a;
        return ans;
}
signed main()
{
    fastio();   
    int tc=1;
   //cin>>tc;
    while(tc--){
     int n;cin>>n;
     int a[n],b[n];
     ain(a,n);ain(b,n);
     int x = maxa(a,n);
     int y =mina(b,n);
     if(x>y)cout<<0;
     else cout<<y-x+1;
} return 0;
    }