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

using ll = long long;

ll n, fib[100];

int main() {
  fib[0] = fib[1] = 1;
  for (int i = 2; i < 100; i++) fib[i] = fib[i - 1] + fib[i - 2];

  cin >> n;
  int m = 86;
  vector<int> ans;
  for (int i = 0; i <= m; i++) {
    if (i % 2 == 0) {
      if (n >= fib[m - i]) {
        ans.push_back(1);
        n -= fib[m-i];
      }
      ans.push_back(4);
    }
    if (i % 2 == 1) {
      if (n >= fib[m - i]) {
        ans.push_back(2);
        n -= fib[m-i];
      }
      ans.push_back(3);
    }
  }

  cout << ans.size() << "\n";
  for (int i = 0; i < ans.size(); i++) cout << ans[i] << "\n";
  return 0;
}
// 首先发现按如下操作序列[4->3->4->3->4->3]操作,结果会呈现fib数字.
// 如果这个序列长度是S,当我们在索引i=2k(i是偶数)之前执行操作1,将会增加fib(S-i)
// 当我们在索引i=2k+1(i是奇数)之前执行操作2,将会增加fib(S-i)
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll read(){
	ll sum=0,f=1;
	char s=getchar();
	while (s<'0' or s>'9'){
		if (s=='-')f=-1;
		s=getchar();
	}
	while (s>='0' and s<='9'){
		sum=sum*10+s-'0';
		s=getchar();
	}
	return sum*f;
}
ll N=1e10*3-1;
bool a[3];
char s[3]={'1','1','0'};
int main(){
	int n=read();
//	while (n--)slove();
	string t;
	cin>>t;
	a[0]=a[1]=a[2]=0;
	for (int p=0;p<3;p++){
		int q=p;
		bool f=1;
		for (int i=0;i<n;i++){
			if (t[i]!=s[q]){
				f=0;
				break;
			}
			q++;
			q%=3;
		}
		a[p]=f;
	}
	ll ans=N-n+1;
	ll maxn=0;
	for (int i=0;i<3;i++){
		if (a[i]==0)continue;
		ll k=ans-i;
		k/=3;
		maxn+=k+1;
//		maxn=max(maxn,3*k+i);
	}
	cout<<maxn;
//	ll x=read();
//	if (x==maxn)cout<<"y";
	return 0;
}


