#include <bits/stdc++.h>
using namespace std;
vector<vector<int>> dp;
vector<vector<pair<int, int>>> p;
void update(int a, int b, int c, int d, int val)
{
if (dp[a][b] >= val) return;
dp[a][b] = val;
p[a][b] = {c, d};
}
int main()
{
int n;
cin >> n;
dp.assign(n + 1, vector<int>(128, 0));
p.assign(n + 1, vector<pair<int, int>>(128, {0, 0}));
for(int i = 1; i <= n; i++)
for(int j = 0; j < (1 << 7); ++j)
{
update(i, j >> 1, i - 1, j, dp[i - 1][j]);
if ((j & 1) || (j & 8)) continue;
update(i, (j >> 1) + 64, i - 1, j, dp[i - 1][j] + 1);
}
int id = 0;
for (int i = 1; i < 128; i++)
if (dp[n][i] > dp[n][id]) id = i;
vector<int> ans;
int mask = id;
int now = n;
while(now)
{
pair<int, int> from = p[now][mask];
if (dp[now][mask] > dp[from.first][from.second])
ans.push_back(now);
now = from.first;
mask = from.second;
}
reverse(ans.begin(), ans.end());
cout << (int)ans.size() << endl;
for(auto i: ans)
cout << i << ' ';
cout << endl;
return 0;
}