#include <stdio.h>
int main() {
    int n=0;
    while (scanf("%d %d", &n) != EOF) 
    { 
        int count=0;
        for(int i=1;i<=n;i++)
        {
            if(i%7==0)
                count++;
            else
            {
                int num=i;
                while(num)
                {
                    if(num%10==7)
                    {
                        count++;
                        break;
                    }
                    else
                        num/=10;
                }
            }
        }
        printf("%d",count);
    }
    return 0;
}