1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
#include <cstdio>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main()
{
  

  string F;
  cin >> F;
  //cout << F << endl;
  
  long long f0 = 0;
  long long f1 = 1;
  //printf("%d\n", f0);
  //printf("%d\n", f1);
  
  
  long long val = 0;
  for (long long i = 0; i < F.size(); i++)
  {
    val = 10LL * val + (F[i] - '0');
  }

  
  long long pot = 1500;
  long long mod = 1000;
  long long z = 3;
  while (z < F.size())
  {
    pot *= 10;
    mod *= 10;
    z++;
  }
  
  if (F.size() == 2)
  {
    mod = 100;
    z = 2;
  }

  if (F.size() == 1)
  {
    mod = 10;
    z = 1;
  }
  
  
  int k = 0;
//  printf("z %lld, pot %lld\n", z, pot);
    int fnPlus1 = 0, fn = 0, fnMin1 = 0;
    bool dz = false;
    for (long long i = 2; i <= pot; i++)
    {
      fnMin1 = f0;
      fn = f1;
      long long f2 = f0 + f1;
      f2 %= 100000000000000LL;
      f0 = f1;
      f1 = f2;
      fnPlus1 = f2;
      
      
      
      //cout << " i " << i << " f2 " << f2 / 1000 << endl;
      
      
      long long g = f2;
      int d = 0;
      if (!dz)
      while (g > 0)
      {
        g /= 10;
        d++;
      }
      
      if (d >= z)
      {
        dz = true;
      }
      
      //printf("i = %lld, d = %d, f2 = %lld.\n", i, d, f2);

      if (dz  && f2 % mod == val)
      {
        printf("%lld\n", i);
        return 0;
      }

          
    }
    //return 0;
    
  printf("NIE\n");

  return 0;
}