title: Count the number of messages in an IMAP folder using Gmail
body: <p>What is the best way to get the total number of messages in a folder on a gmail account? I can get the number of unseen messages like this request/response:</p>
  
  <pre><code>d STATUS "py-lists/pygtk" (UNSEEN)  
  * STATUS "py-lists/pygtk" (UNSEEN 10963)
  </code></pre>
  
  <p>But when I want to get the total number of messages:</p>
  
  <pre><code>e STATUS "py-lists/pygtk" (MESSAGES)
  * STATUS "py-lists/pygtk" (MESSAGES 0)
  </code></pre>
  
  <p>How on earth can the number of unseen messages (10963) be larger than the total number of messages (0)? Am I misunderstanding imap or have I stumbled upon a gmail bug? If so, what can I use as a workaround? Selecting the folder with <code>f SELECT "py-lists/pygtk"</code> works, but isn't great as the select operation can take a very long time to complete.</p>