#include<iostream> #include <string> using namespace std; class BigInt{ private: string s; public: BigInt():s("0"){} BigInt(string& s):s(s){} string ToString(){ return s; } friend BigInt operator+ (BigInt& i1, BigInt& i2); }; BigInt operator+ (BigInt& i1, BigInt& i2){ string s1 = i1.s; string s2 = i2.s; string max,min; max=s1;min=s2; if(s1.length()<s2.length()) { max=s2;min=s1; } int l1=max.size(); int l2=min.size(); int l=l1-1; for(int j=l2-1;j>=0;j--) max[l--] += min[j]-'0'; for(int j=l1-1;j>=1;j--) if(max[j]>'9'){ max[j]-=10; max[j-1]++; } if(max[0]>'9') { max[0]-=10; max='1'+max; } return BigInt(max); } int main(){ BigInt f[1001]; f[0]=f[1]= BigInt( string("1")); f[2]=BigInt(string("2")); f[3]=BigInt(string("4")); for(int i=4;i<=1000;i++) f[i] = f[i-1]+f[i-2]+f[i-4]; int i; while(cin>>i) cout<<f[i].ToString()<<endl; return 1; }