#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,h=0,g,s,b,q,j;
    cin>>n;
    for(int i=1;i<=n;i++){
        g=i%10;
        s=i/10%10;
        b=i/100%10;
        q=i/1000;
        j=g+s+b+q;
        if(j%2!=0&&j%5!=0){
            h++;
        }
    }
    cout<<h;
}
/**************************************************************
	Problem: 1395
	User: linzihang
	Language: C++
	Result: Accepted
	Time:17 ms
	Memory:2072 kb
****************************************************************/