The first nonzero entry that's neither a zero or a two, other the first entry, is the 15th position, 14 zero indexed. So if the input was 4, you would output 14.
This is assuming you have 1 indexed inputs and 0 indexed outputs. You may index your inputs and outputs starting at any constant integers, as long as you can accept the range of inputs corresponding to all sequences.