P23180 [AtCoder] [ABC007D] Forbidden Numbers
提高-
题目描述

Problem Description

The king of Takahashi Kingdom, Lord Takahashi, hates the digits 4 and 9 with a passion. Seeing these digits in his country just makes him feel ill, so he has enacted a law prohibiting their use. Breaking this law will result in punishment. Since these digits are forbidden, any number that has either of these forbidden digits in its decimal representation cannot be used.

Since you can no longer use the numbers you were accustomed to without risking punishment, you have decided to write a program to determine how many forbidden numbers are contained in the interval $[A,B]=\{A,A+1,A+2,...,B\}$. Please create this program.

Input Format

The input is given from the standard input in the following format:

$ A $ $ B $

  • The first line contains two integers $A,B\ (1≦A≦B≦10^{18})$ separated by a space.

Output Format

Output a single line containing the number of forbidden numbers in the interval $ [A,B] $. Ensure a newline at the end of the output.

Sample Input and Output

Sample Input #1

1 9

Sample Output #1

2

Sample Input #2

40 49

Sample Output #2

10

Sample Input #3

1 1000

Sample Output #3

488

Sample Input #4

1 1000000000000000000

Sample Output #4

981985601490518016

Notes/Hints

Partial Points

This problem has two datasets, each with partial points assigned.

  • If you solve dataset 1 where $1\ ≦\ A\ ≦\ B\ ≦\ 10,000$, you will be awarded $ 30 $ points.
  • If you solve dataset 2 without additional constraints, you will be awarded an additional $ 70 $ points separately from the above dataset.

Sample Explanation 1

The digits 4 and 9 are forbidden.

Sample Explanation 2

All numbers from 40 to 49 are forbidden.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
1 9
样例输出
2