#include <iostream>
#include <string>
#include <vector>
#include <cassert>
#include <cstdio>

using namespace std;

string s, t, tmp;

int main()
{
    freopen("fibstring.in", "r", stdin);
    freopen("fibstring.out", "w", stdout);
    int n;
    cin >> n;

    assert(0 <= n && n <= 80);

    if (n < 3)
    {
        cout << "1\n";
        return 0;
    }                         
    t = 'b';
    s = 'a';
    
    for (int i = 2; i <= n; i++)
    {
        tmp = s;
        s += t;
        t = tmp;
    }
    int si = s.length();
    int ans = 1;
    for (int i = 0; i < si; i++)
    {
        int ma = min(i, si - i);
        int len = 0;
        while (len <= ma && s[i - len] == s[i + len])
        {
            len++;
        }
        if (len == ma) ans = max(ans, 2 * ma - 1);
        else ans = max(ans, 2 * len - 1);
        len = 0;
        while (len <= ma && s[i - len] == s[i + 1 + len])
        {
            len++;
        }
        if (len == ma) ans = max(ans, 2 * ma);
        else ans = max(ans, 2 * len);
    }
    cout << ans; 
}