Question 1105054
There are 4 patterns to worry about:

12xxx   —> {{{ 10^3 }}}
x12xx   —>  {{{ 10^3 }}}
xx12x   —> {{{ 10^3 - 10 }}}   <<< minus 10 for the 1212x pattern already counted 
xxx12   —>  {{{ 10^3 - 10 - 10 }}}  <<< minus 20 for 12x12, x1212, both already counted
 ——
That's  {{{ 4x10^3 - 30 }}}  = <b>3970</b> 

——
Check using a Perl one-liner:
 perl -e 'for ($i=0, $s=0; $i<100000; $i++) { if ($i =~ /12/) { $s++; } }; print "$s\n";'
3970