Under construction

Still being built. Things may change

Count Numbers Made Only of 4 and 7

Interview

Time limit2sMemory limit128 MB

Summary
Count integers between A and B (up to 1e9) whose digits are all 4s and 7s.
Level

Easy3 of 10

Topics
Brute force, Combinatorics, Recursion, Math
Solved
No attempts yet

Problem

Call a positive integer good if every digit is either 4 or 7.

Given two positive integers A and B, count how many good integers are between A and B, inclusive.

Input

The first line contains two positive integers A and B, separated by a space.

1 <= A <= B <= 1,000,000,000

Output

Print the number of good integers between A and B, inclusive.

Examples4

  1. Example 1

    Input
    1 10
    
    Expected output
    2
    
  2. Example 2

    Input
    11 20
    
    Expected output
    0
    
  3. Example 3

    Input
    74 77
    
    Expected output
    2
    
  4. Example 4

    Input
    1000000 5000000
    
    Expected output
    64