/*
1. original - 4 sec.
2. Integer with exceptions - 29 sec.
3. value returning using Throw/Catch - >10 min (I think it's no use to wait more)
4. Combination of 1&2 - >10 min
5. Effective algorithm - 0 sec.

System:
Athlon XP 2500+
MSVS2003
*/
#include <stdio.h>
#include <limits>
#include <iostream>

using std::istream;
using std::ostream;
using std::numeric_limits;
using std::cin;
using std::cout;

class overflow_error {};
class divide_by_zero_error {};

class Integer
{
private:
  long long value;
public:
  Integer(long long i=0) {value=i;}
  Integer operator+ (const Integer& a) 
  {
    if(this->value>0 && numeric_limits<long long>::max()-this->value<a.value)
      throw overflow_error();
    if(this->value<0 && numeric_limits<long long>::min()-this->value>a.value)
      throw overflow_error();
    return Integer(this->value+a.value);
  }
  Integer operator- (const Integer& a) 
  {
    if(this->value>0 && numeric_limits<long long>::max()-this->value<-a.value)
      throw overflow_error();
    if(this->value<0 && numeric_limits<long long>::min()-this->value>-a.value)
      throw overflow_error();
    return Integer(this->value-a.value);
  }
  Integer operator/ (const Integer& a) 
  {
    if(a.value==0)
      throw divide_by_zero_error();
    return Integer(this->value/a.value);
  }
  Integer operator- () {return Integer(-this->value);};
  Integer operator+ () {return Integer(this->value);};
  bool operator== (const Integer& a) {return this->value==a.value;}
  bool operator<  (const Integer& a) {return this->value<a.value;}
  bool operator<= (const Integer& a) {return (*this<a) || (*this==a);}
  bool operator>  (const Integer& a) {return !(*this<=a);}
  bool operator>= (const Integer& a) {return !(*this<a);}
  bool operator!= (const Integer& a) {return !(*this==a);}
  Integer& operator= (const Integer& a) {this->value=a.value; return *this;}
  Integer operator++ (int a) {this->value++; return Integer(this->value-1);}
  friend ostream& operator<< (ostream& s, const Integer& i);
  friend istream& operator>> (istream& s, Integer& i);
};

ostream& operator<< (ostream& s, const Integer& i) { return s<<i.value;}
istream& operator>> (istream& s, Integer& i)       { return s>>i.value;}

int fib(int n)
{
  if (n <= 1) return n;
  return fib(n - 1) + fib(n - 2);
}


class fib_exception
{
public:
  Integer value;
  fib_exception(Integer v):value(v) {}
};

void excfibr(Integer n)
{
  if (n <= 1) throw fib_exception(n);
  Integer i1, i2;
  try{ excfibr(n-1); }catch(fib_exception f){ i1=f.value;}
  try{ excfibr(n-2); }catch(fib_exception f){ i2=f.value;}
  throw fib_exception(i1+i2);
}

void coolexcfibr(Integer n)
{
  Integer i1(0);
  Integer i2(1);
  Integer i3(n);
  for(Integer i=2; i<=n; i++)
  {
    i3=i1+i2;
    i1=i2;
    i2=i3;
  }
  throw fib_exception(i3);
}

Integer coolexcfib(Integer n)
{
  try{ coolexcfibr(n); }catch(fib_exception f){ return f.value;}
}

Integer excfib(Integer n)
{
  try{ excfibr(n); }catch(fib_exception f){ return f.value;}
}

int main(void)
{
  Integer n;
  while(cin>>n)
    cout<<coolexcfib(n)<<'\n';
  //scanf("%d");
  return 0;
}
