This page is still under construction.

Parts of this page are still being built. What you see may change.

Digit Count

Interview

Time limit1sMemory limit1024 MB

Summary
Given a range of 4-digit integers and a digit from 0 to 9, count how many times that digit appears across all numbers in the range.
Level

Easy2 of 10

Topics
Implementation, Brute force
Solved
No attempts yet

Problem

There are many ways to count the frequencies of letters. Can the same methods be applied to digits?

Given a range (two integers) and a digit (0-9), count how many times the digit occurs in the range.

Input

There is one input line. It contains the two integers that form the range and the digit. Each integer of the range is between 1000 and 9999 (inclusive), and the digit is between 0 and 9 (inclusive). The first integer of the range is not greater than the second integer.

Output

Print the number of occurrences of the digit in the given range.

Examples4

  1. Example 1

    Input
    1000 1000 0
    
    Expected output
    3
    
  2. Example 2

    Input
    1000 1001 0
    
    Expected output
    5
    
  3. Example 3

    Input
    8996 9004 5
    
    Expected output
    0
    
  4. Example 4

    Input
    9800 9900 5
    
    Expected output
    20