We can describe the valid numbers with a FSA using the digits as alphabet (the upper bound on the number is not yet included):
Here the black numbers at the arrows denote the symbol used for the transition. If there is no such number every symbol that isn't used with another transition is valid. The red numbers denote the number of symbols that that result in the given target state.
3 found yet (initial state)
3 found but no
4 found to the right of the first
4 found to the right of a
3 (final state)
We can represent this as a graph with the following adjacency matrix (weighted with number of symbols that can be used for each transition):
Note that any path in this graph starting at vertex 1 corresponds to a number and every path also ending at vertex 3 is one of the numbers we want to count.
We only need to consider numbers 0, ..., 9999 since 10000 obviously doesn't fit the pattern. Therefore we only need to consider words with exactly 4 symbols ($\rightarrow$ path of length 4 in the graph).
Since we've chosen the edge weights of the graph appropriately the number to calculate can be directly read from last entry in the first row of the matrix