#include <bits/stdc++.h>
#define LOCAL
#define mkp make_pair
#define ft first
#define sd second
using namespace std;
typedef long long ll;
typedef long double lld;
typedef pair<ll,ll> pll;
const lld pi = 3.14159265358979323846;
const ll maxn=1e5+10;
const ll mod=998244353;
void init(void);
ll pow_mod(ll a,ll k);

void solve() {
	ll n,num=0,i=1;
	cin >> n;
	n*=2;
	while(1){
		ll x=n-i*(i-1);
		if(x<=0)break;
		if(x%(2*i)==0)num++;
		i++;
	}
	cout << num*2;
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	//init();
	ll T=1;
	//cin >> T;
	while(T--){
		solve();
	}
	return 0;
} 





void init (void)
{
	#ifdef LOCAL
		freopen ("data.txt", "r", stdin);
		freopen ("out.txt", "w", stdout);
	#endif
}

ll pow_mod(ll a,ll k)
{
    ll ans = 1;
    a %= mod;
    while(k)
    {
        if(k % 2) ans *= a;
        a = (a * a) % mod;
        k /= 2;
        ans %= mod;
    }
    return ans;
}
#include <bits/stdc++.h>
using namespace std;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define X first
#define Y second
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ordered_set tree<pii, null_type,less<pii>, rb_tree_tag,tree_order_statistics_node_update>
#define pf(a) cout<<"checking-- "<<a<<endl
#define pff(a,b) cout<<"Checking-- "<<a<<' '<<b<<endl
#define pfff(a,b,c) cout<<"Checking-- "<<a<<' '<<b<<' '<<c<<endl
#define clr(ar) memset(ar,0,sizeof(ar))
#define gP(n) (prime[n>>6]&(1<<((n>>1)&31)))
#define sP(n) (prime[n>>6]=prime[n>>6]|(1<<((n>>1)&31)))
#define on(val,pos) (val|(1<<pos))
#define off(val,pos) (val&(~(1<<pos)))
#define check(val,pos) (val&(1<<pos))
#define invert(val,pos) (val^(1<<pos))
#define INF (ll) 1e18
#define pie (double)acos(-1.0)
#define vsort(v) sort(v.begin(),v.end())
#define arsort(v,n) sort(v,v+n)
#define MAX 100004
#define MOD 1000000007
vector<tuple<int,int,int>> edges;


void solve(){
    ll n; cin>>n;
    int ans=0;
    for(int i=1;i<=n;i++){
        int num=i;
        int tr=0;
        while(num){
            if(num%10==7) {tr=1;break;}
            num/=10;
        }
        num=i;
        while(num){
            if(num%8==7) {tr=1;break;}
            num/=8;
        }
        if(tr==0) ans++;
    }
    cout<<ans<<endl;

}
int main(){
    int tst=1;
    while(tst--){
        solve();
    }

    return 0;
}
