Option 1: 7 ducks
Duck Duck < 2 in front
Duck < of a duck
Duck < duck in the middle
Duck < a duck
Duck Duck < 2 behind
Option 2: 5 ducks. Duck Duck < 2 in front
Duck < duck in the middle
Duck Duck < 2 behind
Option 3: 3 ducks. Duck A < front of C
Duck B < front of C, middle, behind A
Duck C < behind A
If the interpretations of the riddle are mixed between clauses, any number between 3 and 7 is also possible.