Under construction

Still being built. Things may change

Digit 8

Time limit2sMemory limit512 MB

Summary
Given L and R up to 2*10^9, find the minimum number of times digit 8 appears in any integer within [L, R].
Level

Medium5 of 10

Topics
Math, Greedy, String
Solved
No attempts yet

Problem

Two natural numbers L and R are given. Among all natural numbers greater than or equal to L and less than or equal to R, choose a number that contains the digit 8 as few times as possible. Find how many times the digit 8 appears in such a number.

Input

The first line contains L and R. L is a natural number not greater than 2,000,000,000. R is greater than or equal to L and is also not greater than 2,000,000,000.

Output

Print the minimum possible number of digit 8s among all natural numbers from L to R, inclusive.

Examples4

  1. Example 1

    Input
    1 10
    
    Expected output
    0
    
  2. Example 2

    Input
    88 88
    
    Expected output
    2
    
  3. Example 3

    Input
    800 899
    
    Expected output
    1
    
  4. Example 4

    Input
    8808 8880
    
    Expected output
    2