Calculate how many numbers below N contain digit d.