#include <iostream>
#include <vector>
#include <string.h>
using namespace std;
class Integer
{
public:
Integer(const char* buf, int len)
{
Init(buf, len);
}
Integer() {}
void Init(const char* buf, int len)
{
for (int i = 0; i < len; ++i)
m_data.push_back(buf[i] - '0');
}
void Print()
{
int cnt = m_data.size();
if (cnt <= 0)
cout << "0";
for (int i = 0; i < cnt; ++i)
cout << m_data[i];
}
public:
void Add(const Integer& other, Integer& result) const
{
result.m_data.clear();
int flag = 0;
int i = 0, limit = (other.m_data.size() > m_data.size()) ? other.m_data.size() : m_data.size();
while(i < limit)
{
int num1 = (i < m_data.size()) ? m_data[m_data.size() - 1 - i] : 0;
int num2 = (i < other.m_data.size()) ? other.m_data[other.m_data.size() - 1 - i] : 0;
int sum = num1 + num2 + flag;
flag = sum / 10;
result.m_data.push_back(sum % 10);
++i;
}
if (flag > 0)
result.m_data.push_back(flag);
result.ShrinkAndInvert();
}
void ShrinkAndInvert()
{
while(m_data.size() != 0)
{
if (m_data[m_data.size() - 1] == 0)
m_data.pop_back();
else
break;
}
int cnt = m_data.size();
for (int i = 0; i < cnt / 2; ++i)
{
int tmp = m_data[i];
m_data[i] = m_data[cnt - 1 - i];
m_data[cnt - 1 - i] = tmp;
}
}
bool operator > (const Integer& other) const
{
if (m_data.size() > other.m_data.size())
return true;
if (m_data.size() < other.m_data.size())
return false;
for (int i = 0; i < m_data.size(); ++i)
if (m_data[i] < other.m_data[i])
return false;
else if (m_data[i] > other.m_data[i])
return true;
return false;
}
bool operator == (const Integer& other) const
{
if (m_data.size() != other.m_data.size())
return false;
for (int i = 0; i < m_data.size(); ++i)
if (m_data[i] != other.m_data[i])
return false;
return true;
}
bool operator >= (const Integer& other) const
{
return ((operator > (other)) || (operator == (other)));
}
bool operator < (const Integer& other) const
{
return !(operator >= (other));
}
bool operator <= (const Integer& other) const
{
return !(operator > (other));
}
private:
vector<int> m_data;
};
static void InitFibs(vector<Integer*>& fibs)
{
fibs.push_back(new Integer("1", 1));
fibs.push_back(new Integer("2", 1));
}
static void ClearFibs(vector<Integer*>& fibs)
{
vector<Integer*>::iterator iter = fibs.begin();
while (iter != fibs.end())
{
delete *iter;
++iter;
}
}
static void HowManyFibs(char* a, char* b, vector<Integer*>& fibs)
{
Integer num1(a, strlen(a));
Integer num2(b, strlen(b));
int sum = 0;
bool startToCalculate = false;
vector<Integer*>::iterator iter = fibs.begin();
while(true)
{
if (!startToCalculate)
{
if ((*iter)->operator >= (num1))
{
startToCalculate = true;
}
}
if (startToCalculate)
{
if ((*iter)->operator > (num2))
{
break;
}
else if ((*iter)->operator == (num2))
{
++sum;
break;
}
else
{
++sum;
}
}
++iter;
if (iter == fibs.end())
{
Integer* newFib = new Integer();
(*(iter - 2))->Add(*(*(iter -1)), *newFib);
fibs.push_back(newFib);
iter = fibs.end() - 1;
}
}
cout << sum << endl;
}
#define MAX_SIZE 4096
static void Test()
{
vector<Integer*> fibs;
InitFibs(fibs);
char a[MAX_SIZE], b[MAX_SIZE];
while(true)
{
cin >> a >> b;
if ((a[0] == '0') && (b[0] == '0'))
return;
HowManyFibs(a, b, fibs);
}
ClearFibs(fibs);
}
int main(int argc, char* argv[])
{
Test();
return 0;
}