#include <iostream>
#include <map>
using namespace std;
map <long long, unsigned int> mp;
unsigned int f(const long long n)
{
if (n <= 2)
return 1;
if (mp[n])
return mp[n];
if (n % 2)
return mp[n] = f(6 * n / 7) + f(2 * n / 3);
return mp[n] = f(n - 1) + f(n - 3);
}
int main()
{
long long n;
cin >> n;
cout << f(n) << endl;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8bWFwPgoKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCm1hcCA8bG9uZyBsb25nLCB1bnNpZ25lZCBpbnQ+IG1wOwoKdW5zaWduZWQgaW50IGYoY29uc3QgbG9uZyBsb25nIG4pCnsKCWlmIChuIDw9IDIpCgkJcmV0dXJuIDE7CgoJaWYgKG1wW25dKQoJCXJldHVybiBtcFtuXTsKCglpZiAobiAlIDIpCgkJcmV0dXJuIG1wW25dID0gZig2ICogbiAvIDcpICsgZigyICogbiAvIDMpOwoKCXJldHVybiBtcFtuXSA9IGYobiAtIDEpICsgZihuIC0gMyk7Cn0KCmludCBtYWluKCkKewoJbG9uZyBsb25nIG47CgljaW4gPj4gbjsKCWNvdXQgPDwgZihuKSA8PCBlbmRsOwp9