4. Let the three-digit number $n=\overline{a b c}$, where the lengths $a, b, c$ can form an isosceles (including equilateral) triangle. Then the number of such three-digit numbers $n$ is. $\qquad$
4. 165.

When $a=b=c$, there are 9 cases in total.
When $a=b \neq c, a=c \neq b, b=c \neq a$, the number of cases for each situation is the same. Taking $a=b \neq c$ as an example:
(1) When $a=b \geqslant 5$, $a$ and $b$ have 5 cases, and $c$ has 8 cases, making a total of 40 cases;
(2) When $a=b=4$, $c$ can be any one from the set $\{1,2,3,5,6,7\}$, making a total of 6 cases;
(3) When $a=b=3$, $c$ has 4 cases;
(4) When $a=b=2$, $c$ has 2 cases.
In summary, there are $3 \times(40+6+4+2)+9=165$ cases in total.