PeterTree:
How can I connect the flow sensor to D2 (3.3V)?
Do I need to use a converter or something?
You don't. It's a signal output, not a power supply.
You really don't have higher voltage elsewhere in your circuit? Then - short of getting a flow sensor that works at 3.3V - the only option you have left is a step-up converter. Of course the input power of the converter does not come out of your Arduino but directly from whatever power source you have available.
Max Output Current : 15mA @ 5VDC
Here is another problem: you can't connect this directly to your Arduino either but this is easier: just put a level shifter in between, and you should be good to go and start counting pulses.