Let $d$ be the number of digits of $N$. Suppose that $N$ does not itself have leftmost digit 1 . Then the number of integers $1,2, \ldots, N$ which have leftmost digit 1 is $$1+10+10^{2}+\ldots+10^{d-1}=\frac{10^{d}-1}{9}$$ so we must have $\frac{10^{d}-1}{9}=\frac{2 N}{5}$, or $5\left(10^{d}-1\right)=18 N$. But the left-hand side is odd, so this is impossible. Thus $N$ must have leftmost digit 1 . In this case, the number of integers $1,2, \ldots, N$ which have leftmost digit 1 is $$\begin{aligned} & 1+10+10^{2}+\ldots+10^{d-2}+\left(N-10^{d-1}+1\right) \\ = & \frac{10^{d-1}-1}{9}+N-10^{d-1}+1 \\ = & N-8\left(\frac{10^{d-1}-1}{9}\right) \end{aligned}$$ Therefore we need $N-8\left(\frac{10^{d-1}-1}{9}\right)=\frac{2}{5} N$, or $N=\frac{40}{3}\left(\frac{10^{d-1}-1}{9}\right)$. Then, $\frac{10^{d-1}-1}{9}$ must be divisible by 3. The base-ten representation of $\frac{10^{d-1}-1}{9}$ has $d-1$ ones, so $d-1$ must be divisible by 3 . Both $d=1$ and $d=4$ make $N$ less than 2017, but $d=7$ gives the answer $N=\frac{40}{3}(111111)=1481480$.
Michael writes down all the integers between 1 and $N$ inclusive on a piece of paper and discovers that exactly $40 \%$ of them have leftmost digit 1 . Given that $N>2017$, find the smallest possible value of $N$.