So, when the log ends with n(S) = 2, n(F) = 0 and n(T) = 0, 1, ..., 4

With n(T) = 0, there is just one possible log: S, S.

With n(T) = 1, there are two possible logs: T, S, S and S, T, S.

With n(T) = 2, the number of logs is the number of ways of choosing which position 1, 2 or 3 the S will come, which is 3,

With n(T) = 3, the number of logs is 4.

With n(T) = 4, the number of logs is 5.

Total for n(S) = 2 is 1 + 2 + 3 + 4 + 5 = 15

If n(T) = 5, then once again n(F) = 0, and n(S) = 0 or 1.

If n(S) = 0, there is just one log.

If n(S) = 1, there are 5 positions in which the S could come.

So the total for n(T) = 5 is 1 + 5 = 6

If n(F) = 1, then the F must come at the end of the sequence, with n(S) = 0, 1 and n(T) = 0, 1, ..., 4

If n(S) = 0, there are 5 possible logs, corresponding to each of the five values of n(T).

If n(S) = 1, there are 1 + 2 + 3 + 4 + 5 = 15 possible logs (each of
these individual numbers being the number of ways of positioning the S
with 0, 1, ..., 4 T's)

So the total for n(F) = 1 is 5 + 15 = 20

So I reckon the overall total is 15 + 6 + 20 = 41 logs