#include <bits/stdc++.h>
using namespace std;
template <typename _T>
inline void _DBG(const char *s, _T x) {
  cerr << s << " = " << x << "\n";
}
template <typename _T, typename... args>
void _DBG(const char *s, _T x, args... a) {
  while (*s != ',') cerr << *s++;
  cerr << " = " << x << ',';
  _DBG(s + 1, a...);
}
vector<pair<long long, long long> > v = {
    {1, 1},      {2, 1},     {4, 1},      {5, 1},      {9, 1},      {10, 1},
    {20, 1},     {21, 1},    {41, 1},     {42, 1},     {84, 1},     {85, 1},
    {169, 1},    {170, 1},   {340, 1},    {341, 1},    {681, 1},    {682, 1},
    {1364, 1},   {1365, 1},  {2729, 1},   {2730, 1},   {5460, 1},   {5461, 1},
    {10921, 1},  {10922, 1}, {21844, 1},  {21845, 1},  {43689, 1},  {43690, 1},
    {87380, 1},  {87381, 1}, {174761, 1}, {174762, 1}, {349524, 1}, {349525, 1},
    {699049, 1}, {699050, 1}};
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  for (auto p : v) {
    if (p.first == n) {
      cout << p.second << "\n";
      return 0;
    }
  }
  cout << 0 << "\n";
  return 0;
}
