You never specified that the two ducks had to be in front of / behind the middle duck.
If there are 97 ducks in a line, there are 2 ducks in front of the third duck from the front, two ducks behind the 95th duck and a duck (number 49) in the middle.
Therefore, any odd number greater than 1 answers the question correctly, as stated.
The question was as stated originally.
2 ducks in front of a duck = 3
That's the starting point.
Next -
So there are only 3 ducks.
Next - 2 ducks behind a duck, gives 2 ducks behind the first duck, of the three.
And there are still only 3 ducks.
Of the 3 ducks that are there, there is one in the middle, so the answer is - 3.