/**
    Lost Arrow (Aryan V S)
    Saturday 2020-12-19
**/

#ifdef LOST_IN_SPACE
#  if   __cplusplus > 201703LL
#    include "lost_pch1.h" // C++20
#  elif __cplusplus > 201402LL
#    include "lost_pch2.h" // C++17
#  else
#    include "lost_pch3.h" // C++14
#  endif
#else
#  include <bits/stdc++.h>
#endif

constexpr bool test_cases = false;

void solve () {
    int n;
    std::cin >> n;
    int cnt = 0;
    for (int i = 1; i <= n; ++i) {
        std::string base10 = std::to_string(i);
        std::string base8;
        int j = i;
        while (j) {
            base8 += '0' + (j % 8);
            j /= 8;
        }
        bool bad = false;
        for (char c : base10)
            if (c == '7')
                bad = true;
        for (char c : base8)
            if (c == '7')
                bad = true;
        if (!bad)
            ++cnt;
    }
    std::cout << cnt << '\n';
}

int main () {

    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    std::cout.precision(10);
    std::cerr.precision(10);
    std::cout << std::fixed << std::boolalpha;
    std::cerr << std::fixed << std::boolalpha;

    int32_t cases = 1;
    if (test_cases)
        std::cin >> cases;
    while (cases--)
        solve();

    return 0;
}

// g++.exe -Wall -Weffc++ -Wextra -pedantic -std=c++20 -g -D_GLIBCXX_DEBUG -DLOST_IN_SPACE -H

// Replace failing with learning
// Replace overthinking with action
// Replace blame with responsibility
// Replace toxic friends with mentors
// Replace complaining with gratitude
// Replace netflix marathons with sleep
// Replace fake influencers with inspiring creators

#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
#define ld long double 
#define pb push_back
#define pob pop_back
#define ub upper_bound
#define lb lower_bound
#define mp make_pair
#define f0(i,n) for(i=0;i<n;i++)
#define rf0(i,n) for(i=n-1;i>=0;i--)
#define f2(i,n) for(i=1;i<n;i++)
#define f1(i,n) for(i=1;i<=n;i++)
#define fab(i,a,b) for(i=a;i<=b;i++)
#define shr  ll t;cin>>t; while(t--)
#define fi first
#define sc second
#define pll pair<ll,ll>
#define vll vector<ll>
#define vpll vector<pll>
#define all(v) v.begin(),v.end()
#define mod 1000000007
#define dev(a) for(auto it:a)cout<<it<<" "
#define prec(nm,prc) cout<<fixed<<setprecision(nm)<<prc<<" "
#define print(a) cout<<a<<"\n";
#define print2(a,b) cout<<a<<" "<<b<<"\n";
#pragma GCC optimization ("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#define nl cout<<"\n"
#define ye cout<<"Yes\n"
#define yee cout<<"YES\n"
#define no cout<<"No\n"
#define noo cout<<"NO\n"
#define ln length()
#define ms(cnt,r) memset(cnt, r, sizeof(cnt))
using namespace std;
bool comp(pll &a,pll &b)
{
    return (a.sc<b.sc);
}
ll power(ll n,ll p)
{
	if(p==0)
	return 1;
	else
	{
		ll ans=power(n,p/2)%mod;
		ans=(ans*ans)%mod;
		if(p%2==0)
		return ans;
		else
		return ans=(ans*n)%mod;
	}
}
bool isPrime(ll n) 
{ 
    if (n <= 1) 
        return false; 
    if (n <= 3) 
        return true; 
  
    if (n % 2 == 0 || n % 3 == 0) 
        return false; 
  
    for (ll i = 5; i * i <= n; i = i + 6) 
        if (n % i == 0 || n % (i + 2) == 0) 
            return false; 
  
    return true; 
} 
    /********************HAR HAR MAHADEV***********JAI BAJRANG BALI************************/
  int main()
 {
  	FAST;
  	/* ifstream cin;
    cin.open("input.txt");
    ofstream cout;
    cout.open("output.txt");
                      */
  	//shr
  	  {  
  	  	ll i,j,n,a,b,c,d,m,sum=0,ans=0,cnt=0,r=0,e=0;
  	  	string str,s1,om,s;
  	     unordered_map<ll,ll>mp,mp1;
  	     set<ll>st; vll v; 
  	     cin>>a;
  	     n=sqrt(a);
  	     fab(i,1,n)
  	     {
  	         if(a%i==0)
  	         {
  	             e=a/i;
  	             if(i%2==1)r++;
  	             if(e%2==1)r++;
  	             if(i==e&&i%2==1)r--;
  	         }
  	     }
  	    cout<<(r*2);
  	     
  	     
  	  }
   	return 0;
  }                     
 