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

int64_t X,Y,R;

int64_t in(){
    double x; cin >> x;
    return round(10000*x);
}


int64_t f(){
    int64_t cnt=0;
    
    int64_t yUpper;
    if(R+Y>=0){
        yUpper=(R+Y)-((R+Y)%10000);
    }else{
        if((R+Y)%10000!=0) yUpper=(R+Y)-(10000+(R+Y)%10000);
        else yUpper=(R+Y);
    }

    int64_t x1,x2;
    if(X>=0){
        x1=X+(10000-X%10000);
        x2=X-X%10000;
    }else{
        x1=X-X%10000;
        x2=X-(10000+X%10000);
    }
    
    int64_t c1=0,c2=0;
    while(yUpper>=Y){
        int64_t u=yUpper-Y;
        while(true){
            int64_t s=x1-X,t=X-x2;
            
            if(s*s + u*u > R*R && t*t + u*u > R*R){
                cnt+=c1+c2;
                break;
            }

            if(s*s + u*u <= R*R){
                x1+=10000;
                c1++;
            }
            if(t*t + u*u <= R*R){
                x2-=10000;
                c2++;
            }
        }
        yUpper-=10000;
    }


    int64_t yLower;
    if(Y-R<0){
        yLower=(Y-R)-((Y-R)%10000);
    }else{
        if((Y-R)%10000!=0) yLower=(Y-R)+(10000-(Y-R)%10000);
        else yLower=(Y-R);
    }
    
    int64_t x3,x4;
    if(X>=0){
        x3=X+(10000-X%10000);
        x4=X-X%10000;
    }else{
        x3=X-X%10000;
        x4=X-(10000+X%10000);
    }

    int64_t c3=0,c4=0;
    while(yLower<Y){
        int64_t u=Y-yLower;
        while(true){
            int64_t s=x3-X,t=X-x4;
            
            if(s*s + u*u > R*R && t*t + u*u > R*R){
                cnt+=c3+c4;
                break;
            }

            if(s*s + u*u <= R*R){
                x3+=10000;
                c3++;
            }
            if(t*t + u*u <= R*R){
                x4-=10000;
                c4++;
            }
        }
        yLower+=10000;
    }
    return cnt;
}

int main(){
    X=in(); Y=in(),R=in();
    cout << f() << endl;
    return 0;
}
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);  cin.tie(NULL);
#define ll long long
#define min3(a,b,c) min(min((a),(b)),(c))
#define min4(a,b,c,d) min(min((a),(b)),min((c),(d)))
#define max3(a,b,c) max(max((a),(b)),(c))
#define max4(a,b,c,d) max(max((a),(b)),max((c),(d)))
#define S second
#define F first
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*b)/gcd(a,b)
#define PI 3.14159265358979323846;
#define MOD 1000000007
using namespace std;

bool check1 (int n)
{
    while(n)
    {
        int r = n % 10;

        if(r == 7)
            return true;

        n /= 10;
    }

    return false;
}

bool check2 (int n)
{
    while(n)
    {
        int r = n % 8;

        if(r == 7)
            return true;

        n /= 8;
    }

    return false;
}

int main()
{
    FAST;

    int n;
    cin >> n;

    int c = 0;

    for(int i = 1; i <= n; i++)
    {
        if(check1(i) || check2(i))
        {
            c += 1;
        }
    }

    cout << n - c << "\n";
    
    return 0;
}