#P4124. Mobile Number Feature Count

    ID: 17372 Type: Default 1000ms 256MiB

Mobile Number Feature Count

Mobile Number Feature Count

Given two 11-digit mobile phone numbers L and R (with no leading zeros), count the number of phone numbers in the interval [L, R] that satisfy the following two conditions:

  1. The number must contain at least three consecutive identical digits. In other words, there exists an index \(i\) such that \(d_i = d_{i+1} = d_{i+2}\).
  2. The number should not contain both the digits \(8\) and \(4\) simultaneously.

For example, the phone numbers 13000988721, 23333333333, and 14444101000 satisfy both conditions, whereas 1015400080 and 10010012022 do not.

Input consists of two 11-digit numbers L and R with \(L \le R\). Output the count of valid phone numbers in the interval [L, R].

inputFormat

The input consists of two space-separated 11-digit numbers L and R.

outputFormat

Output a single integer denoting the number of phone numbers in [L, R] that satisfy the conditions.

sample

13000988721 13000988721
1