All natural numbers from $1$ to $N$, $ N \ge 2$ are written out in a certain order in a circle. Moreover, for any pair of neighboring numbers there is at least one digit appearing in the decimal notation of each of them. Find the smallest possible value of $N$.