#include<bits/stdc++.h>
using namespace std;
#define MAXN 200005
#define lowbit(x) (x&-x)
#define reg register
#define mp make_pair
#define fir first
#define sec second
typedef long long LL;
typedef unsigned long long uLL;
const int INF=0x3f3f3f3f;
const int mo=1e9+7;
const int iv2=5e8+4;
const int lim=1000000;
const int jzm=1e6+7;
const int orG=3,invG=332748118;
const double Pi=acos(-1.0);
typedef pair<LL,LL> pii;
const double PI=acos(-1.0);
template<typename _T>
_T Fabs(_T x){return x<0?-x:x;}
template<typename _T>
void read(_T &x){
	_T f=1;x=0;char s=getchar();
	while(s>'9'||s<'0'){if(s=='-')f=-1;s=getchar();}
	while('0'<=s&&s<='9'){x=(x<<3)+(x<<1)+(s^48);s=getchar();}
	x*=f;
}
template<typename _T>
void print(_T x){if(x<0){x=(~x)+1;putchar('-');}if(x>9)print(x/10);putchar(x%10+'0');}
int gcd(int x,int y){return !y?x:gcd(y,x%y);}
int add(int x,int y){return x+y<mo?x+y:x+y-mo;}
LL n,ans[2005],tot;pii f[2005];
pii solve1(pii tmp){return mp(tmp.fir+1LL,tmp.sec);}
pii solve2(pii tmp){return mp(tmp.fir,tmp.sec+1LL);}
pii solve3(pii tmp){return mp(tmp.fir+tmp.sec,tmp.sec);}
pii solve4(pii tmp){return mp(tmp.fir,tmp.sec+tmp.fir);}
void extend(LL id){
	tot=id;
	while(f[tot].fir+f[tot].sec<=n){
		if(f[tot].fir<=f[tot].sec)tot++,f[tot]=solve3(f[tot-1]),ans[tot]=3;
		else tot++,f[tot]=solve4(f[tot-1]),ans[tot]=4;
	}
}
LL check(LL id){return n-f[id].fir+id;}
void print(){
	while(f[tot].fir<n)++tot,f[tot]=solve1(f[tot-1]),ans[tot]=1;
	printf("%d\n",tot);for(int i=1;i<=tot;i++)printf("%d\n",ans[i]);
}
signed main(){
	read(n);f[1]=solve2(f[0]);ans[1]=2;f[2]=solve1(f[1]);ans[2]=1;tot=2;extend(tot);
	if(check(tot)<=130){print();return 0;}
	for(int i=3;i<=tot;i++){
		LL las=check(tot);pii ls=f[i];int lasway=ans[i];f[i]=solve1(f[i-1]);ans[i]=1;extend(i);
		if(check(tot)>=las)f[i]=ls,ans[i]=lasway,extend(i);
		//printf("%d:%lld %lld %lld %lld\n",i,f[i].fir,f[i].sec,check(tot),las);
		las=check(tot);ls=f[i];lasway=ans[i];f[i]=solve2(f[i-1]);ans[i]=2;extend(i);
		if(check(tot)>=las)f[i]=ls,ans[i]=lasway,extend(i);
		//printf("%d:%lld %lld %lld %lld\n",i,f[i].fir,f[i].sec,check(tot),las);
		las=check(tot);ls=f[i];lasway=ans[i];f[i]=solve3(f[i-1]);ans[i]=3;extend(i);
		if(check(tot)>=las)f[i]=ls,ans[i]=lasway,extend(i);
		//printf("%d:%lld %lld %lld %lld\n",i,f[i].fir,f[i].sec,check(tot),las);
		las=check(tot);ls=f[i];lasway=ans[i];f[i]=solve4(f[i-1]);ans[i]=4;extend(i);
		if(check(tot)>=las)f[i]=ls,ans[i]=lasway,extend(i);
		//printf("%d:%lld %lld %lld %lld\n",i,f[i].fir,f[i].sec,check(tot),las);
		if(check(tot)<=130){print();return 0;}
		//printf("nxt %lld %lld\n",f[i+1].fir,f[i+1].sec);
	}
	print();
	return 0;
}
/*
0 1
1 1
1 2
*/
#include <bits/stdc++.h>
#include <bits/extc++.h>
#define double long double
#define rbtree __gnu_pbds::tree<int,__gnu_pbds::null_type,less<int>,__gnu_pbds::rb_tree_tag,__gnu_pbds::tree_order_statistics_node_update>
#define int ll
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);
#define pb push_back
#define ALL(X) X.begin(),X.end()
#define F(i,n)  FF(i,0,n)
#define F1(i,n)  FF(i,1,n+1)
#define FF(i,n,m) for(int i=(int)n;i<(int)m;++i)
#ifndef LOCAL
//#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector")
#else
#endif // LOCOL
//#define mp make_pair
using namespace std;
//using namespace __gnu_pbds;
template<typename T> bool remax(T& a, const T& b) {return b>a?a=b,1:0;}
template<typename T> bool remin(T& a, const T& b) {return b<a?a=b,1:0;}
inline ostream& operator << (ostream& os,__int128_t a){if(a==0) {return (os<<'0');}bool flag=0;if(a<0) {a=-a,flag=1;}string s;while(a){s+=a%10+'0';a/=10;}s+=flag?"-":"";reverse(ALL(s));return os<<s;}
inline istream& operator >>(istream& is,__int128_t& a){string s;cin>>s;a=0;for(auto c:s) a=a*__int128_t(10)+__int128_t(c-'0');return is;}
template<typename T,typename P> inline ostream& operator << (ostream& os,pair<T,P> a){os<<a.first<<" "<<a.second; return os;}
template<typename T,typename P> inline istream& operator >> (istream& is,pair<T,P> &a){is>>a.first>>a.second; return is;}
using ll=long long;
using ull=unsigned long long;
using int128= __int128_t;
using uint128= __uint128_t;
using pii =pair<int,int>;
const double pi=acos(-1);
const int N=1E5+5;
const ll M=1000000000;
const ll INF_64=0x3f3f3f3f3f3f3f3f;
const int INF_32=0x3f3f3f3f;
const int16_t INF_16=0x3f3f;
const int klog=20;
const int mod=1E9+7;//998244353
const double eps=1E-8;
void gen(){
}
vector<int> an;
bool DD(int x,int y){
    if(x==0||y==0){
        if(an.size()+x+y>130) return false;
        while(x--) an.pb(1);
        while(y--) an.pb(2);
        return true;
    }
    if(x>=y)
        x-=y,an.pb(3);
    else y-=x,an.pb(4);
    return DD(x,y);
}
int re(){
    int x=0,y=0;
    F(i,an.size()){
        if(an[i]==1) x++;
        else if(an[i]==2) y++;
        else if(an[i]==3) x+=y;
        else if(an[i]==4) y+=x;
    }

    return x;
}
void sol(){
    int n;
    cin>>n;
    std::random_device rd;
    std::default_random_engine gen = std::default_random_engine(rd());
    std::uniform_int_distribution<int> dis(n/4,3*n/4);
    int tt;

    if(n<=130){
        cout<<n<<"\n";
        F(i,n) cout<<1<<"\n";
        return;
    }
    while(tt=dis(gen)){
        an.clear();
        an.pb(3);
        if(!DD(tt,n-tt)) continue;
        //cerr<<tt<<"\n";
        cout<<an.size()<<"\n";
        reverse(ALL(an));
        assert(re()==n);
        F(i,an.size()) cout<<an[i]<<"\n";
        return;
    }

}
int32_t main(){
    #ifdef LOCAL
    //freopen(".in","r",stdin);
    //freopen(".out","w",stdout);
    #endif // LOCAL
    IOS;
    int t=1;
    gen();
    //cin>>t;
    FF(i,1,t+1){
        //cout<<"Case #"<<i<<": ";
        sol();
    }
}
