#include <stdio.h>
#include <stdlib.h>

int fibo(int n)
{
    if (n == 0)
        return 0;
   /* else
        if (n == 1)
          return 1;
    else
        return fibo(n-1)+fibo(n-2);
        */
    int next, first, second, c;
    first = 0; second = 1;
    for (c = 0 ; c < n ; c++)
    {
      if (c <= 1)
         next = c;
      else
      {
         next = first + second;
         first = second;
         second = next;
      }
    }
      return next;
}

int verif_fibo(int x)
{
    int check;
    check = x;
    while (!(fibo(check) < x))
    {
        check--;
    }
    return check - 1;
}
int main()
{
    int n;
    do{
    scanf("%d", &n);
    }while(!(n>=1) && (n < 10000000));
    printf("%d", verif_fibo(n));
    return 0;
}