/*
	JAI JAGANNATH!
*/
//@Author : zanj0

#include<bits/stdc++.h>
using namespace std;

#define int 			long long int

#define ff              first
#define ss              second
#define pb              push_back
#define MOD             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(x)            int x; cin>>x; while(x--)
#define endl       		"\n"
#define timetaken cerr<<"Time : "<<1000*(long double)clock()/(long double)CLOCKS_PER_SEC<<"ms\n"

void zanj0()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
const int MAX = 3e6 + 5;
int fac[MAX], finv[MAX];
int inv[MAX];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}
int COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int add(int a, int b) {
	return ((a % MOD) + (b % MOD)) % MOD;
}
int mul(int a, int b) {
	return ((a % MOD) * (b % MOD)) % MOD;
}
int fastPow(int base, int p) {
	int ret = 1;
	while (p) {
		if (p & 1) ret = mul(ret, base);
		base = mul(base, base);
		p >>= 1;
	}
	return ret;
}
int sub(int a, int b) {
	return (((a % MOD) - (b % MOD)) + MOD) % MOD;
}
void solve() {
	int n, m, k;
	cin >> n >> m >> k;
	COMinit();
	if (n > m + k) {
		cout << 0 << endl;
	} else if (k >= n) {
		cout << COM(n + m, n) << endl;
	} else {
		cout << sub(COM(n + m, n), COM(n + m, m + k + 1)) << endl;
	}

}
int32_t main()
{
	zanj0();
	solve();
	timetaken;
	return 0;
}
/**
*    author: zakhio (mttk1528)
*    created: 19.12.2020 21:02:51
**/
// #pragma GCC target("avx2")
// #pragma GCC optimize("O3")
// #pragma GCC optimize("unroll-loops")

#ifdef _LOCAL_
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>
using namespace std;

#define name(x) #x
#define dump(x) cout << name(x) << " = " << x << endl
#define print(x) cout << (x) << endl
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define rrep(i,n) for (int i = (int)(n - 1); i >= 0; i--)
#define rep2(i,s,n) for (int i = (s); i < (int)(n); i++)
#define len(x) (int)(x.size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pcnt(bit) ll(__builtin_popcountll(bit))
#define roundup(x,y) (x + y - 1) / y

using ll = int64_t;
using pll = pair<ll,ll>;
using pii = pair<int,int>;
using pil = pair<int,ll>;
using pli = pair<ll,int>;

const double pi = acos(-1.0);
const ll LINF = 1e18;
const int INF = 1e9;
const int MAX = 1000010;
const int MOD1 = 1000000007;
const int MOD2 = 998244353;
const int di[4] = {1, 0, -1, 0};
const int dj[4] = {0, 1, 0, -1};
const int di2[8] = {0, 1, 0, -1, 1, 1,-1, -1};
const int dj2[8] = {1, 0,-1, 0, 1, -1, 1, -1};

template <typename T> inline bool chmax(T &a, T b) {if (a < b) {a = b; return 1;} return 0;}
template <typename T> inline bool chmin(T &a, T b) {if (b < a) {a = b; return 1;} return 0;}
template <typename T> T bpow(T a, int n) {T r(1); while(n) {if (n & 1) r *= a; a *= a; n >>= 1;} return r;}
template <typename T> auto comp(vector<T> a) {sort(all(a)); a.erase(unique(all(a)),a.end()); return a;}
template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T,U> &p) {os << p.first << " " << p.second; return os;}
template <typename T, typename U> ostream &operator<<(ostream &os, const map<T,U> &mp) {for (auto p : mp) {os << "[" << p << "]\n";} return os;}
template <typename T> ostream &operator<<(ostream &os, const vector<T> &v) {rep(i,len(v)) {if (i) os << " "; os << v[i];} return os;}
template <typename T> ostream &operator<<(ostream &os, const set<T> &st) {int c(0); for (auto x : st) {if(c) os << " "; os << x; c++;} return os;}
template <typename T> istream &operator>>(istream &i, vector<T> &v) {rep(j,len(v)) i >> v[j]; return i;}
template <typename T, typename U> istream &operator>>(istream &i, pair<T,U> &p) {i >> p.first >> p.second; return i;}

string convert_base(int a, int base) {
    if (a == 0) return "0";
    string str;
    while (a) {
        int rest = a % base;
        str += to_string(rest);
        a /= base;
    }
    reverse(all(str));
    return str;
}

void solve() {
    
    int n; cin >> n;

    int ans = 0;

    rep(i,n) {
        int num = i+1;
        bool ok = true;
        string s1 = to_string(num);
        string s2 = convert_base(num, 8);
        rep(j,len(s1)) if (s1[j] == '7') ok = false;
        rep(j,len(s2)) if (s2[j] == '7') ok = false;
        if (ok) ans++;
    }
    
    print(ans);
    return;
}

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    // cout << fixed << setprecision(15);
    solve();
    return 0;
}