The letter "F" may always be typed, whichever hand is being used. Therefore, occurrences of "F" in (W) have no bearing on which hand Timmy chooses to use, and may be ignored.
This leaves us with a reduced string (W') of relevant letters, each being either "X" (only typeable with Timmy's left hand) or "O" (only typeable with his right hand). Whenever a "X" is followed by an "O" in (W'), Timmy must switch from his left hand to his right, and vice versa whenever an "O" is followed by a "X". Therefore, (F(W)) is equal to the number of pairs of consecutive differing letters in (W').