IMAP: fix flag counter