As an attacker you may stay in the opponents' paint for a maximum of three seconds at a time while your team controls the ball in the frontcourt. Breach it and you lose the ball.
Few whistles feel as arbitrary to a beginner — after all, you were only standing where your coach wants you. That is exactly the point: the rule stops a big man from setting up camp under the rim. The count starts the moment one foot touches the paint and only stops once both feet are back outside, so lifting a foot for a second resets nothing. The classic beginner error is treating this as a question of position. It is a question of movement: step in, make contact, step out, offer again. And here is the distinction that starts arguments at club level: the version for defenders, who may not sit in the paint for more than three seconds without actively guarding someone, exists only in leagues such as the NBA. Under FIBA rules zone defence is entirely legal.