#include <vector>
#include <iostream>
using namespace std;
static vector<int> louti;
int zoulouti1(int n)
{
if(n <= louti.size()) // 已经计算过的楼梯级,直接返回vector里面的值即可
return louti[n - 1];
int i = louti.size();
while(i < n) {
// f(n) = f(n - 1) + f(n - 2) + f(n - 3)
int zoufa = louti[i - 1] + louti[i - 2] + louti[i - 3];
louti.push_back(zoufa);
++i;
}
return louti.back();
}
void init_louti()
{
// 只有1、2、3级楼梯,对应的走法
louti.push_back(1);
louti.push_back(2);
louti.push_back(4);
}
int main()
{
int n = 0;
cin >> n;
init_louti();
cout << zoulouti1(n) << endl;
}