Find the number of five-digit numbers less than 40 000 in which the three three-digit numbers formed by consecutive digits are all divisible by either 17 or 23. Remember, zero cannot be the first digit in a three-digit number.

A number is divisible by 17 if and only if the alternating sum of its digits is divisible by 17. A number is divisible by 23 if and only if the sum of its digits is divisible by 23. Thus, we can rewrite the problem in terms of the digits of the number.

Let $a,b,c,d,e$ represent the digits of the number such that the number is $ab,cde$. If we consider the three-digit number $abc$, then its digits must satisfy either of the following conditions:
$(1)$ The alternating sum of the digits is divisible by $17$, and $a \ne c$
$(2)$ The sum of the digits is divisible by $23$, and $a = c$
Notice that both $a,c$ cannot be divisible by $17$ and $23$, as $(17, 23) = 1$, so we do not consider that.

For condition $(1)$, note that we have the following possible digit sets, taking $(mod 17)$.
\[\{1, 6, 8\}, \{1,3,15\}, \{2,4,13\}, \{2,6,12\}, \{2,11,14\}, \{3,8,14\}, \{4,6,7\}, \{4,11,12\}, \{7,8,9\}, \{7,11,15\},\{9,13,15\}, \{9,12,14\}\]
Now, $b = a + d - c \implies d \equiv c-b \pmod{17}$. We have taken care of $(2)$ already, so now we bash through these sets specifically for the first condition.

$\{1, 6, 8\}$ gives us $d \equiv 8-b\pmod{17}$, which will give us $8$ possibilities.
Similar to the above, the second set will give us $2$ possibilities, and so on.

For condition $(2)$, the sum of all three digits is represented by $3a + d \equiv 0 \pmod{23}$. Thus, $d$ is determined by $a$ modulo $23$. Not all values of $a$ modulo 23 will work, but given $a \pmod{23}$, the value of $d$ that satisfies $3a + d \equiv 0 \pmod {23}$ is unique.

Thus, we see that each of the $12$ sets will give us $10$ possibilities for $a,d$, although we must be careful with $c$ as $c=0$. We count only when the digit sets call for a zero.

For example, the set $\{1,6,8\}$ gives us $10 \cdot 10 - 10 = 90$ possible numbers, as $a,d$ can each be chosen in $10$ ways, but we exclude $16,26,\cdots,96$, so as not to overcount.

Doing this process with all of the cases, our answer is $8 + 2 + 2 + 4 + 4 + 2 - 10 + (10 \cdot 10 - 10) \cdot 5 + (10 \cdot 10 - 10) \cdot 12 - 1 = \boxed{726}$. The $1$ is subtracted as there is the overlap $ab = 1700$.