To count the total number of folders in use within a mailbox, first connect Powershell to Exchange Online, then:
$MailboxToCountFoldersWithin = Get-Mailbox username $MailboxToCountFoldersWithin | Get-MailboxFolderStatistics | Measure-Object | Select-Object -ExpandProperty Count
The total number of folders, will be output as a number.