Numbers That Read the Same Upside Down

No attempts yetTime limit1sMemory limit128 MB

Problem

The digits $0$, $1$, and $8$ look almost the same when the page is rotated $180$ degrees (turned upside down). The digit $6$ looks like a $9$ when rotated this way, and $9$ looks like a $6$.

A multi-digit number can also look like itself when the page is turned upside down. For example, $9966$ and $10,801$ do, but $999$ and $1234$ do not.

Write a program that counts how many numbers in a given interval look the same after being rotated $180$ degrees. For example, the interval $[1 \dots 100]$ contains six such numbers: $1$, $8$, $11$, $69$, $88$, and $96$.

Input. Two integers $m$ and $n$ that define the interval to check ($1 \le m \le n \le 32,000$). You may assume the input is always valid.

Output. Print how many numbers in $[m, n]$ look the same when rotated $180$ degrees.