When working with the Azure AD Sync Services Tool (a.k.a. DirSync), you’ll often end up with user accounts synced up to Azure AD that you don’t need and will never license. This typically happens during the initial sync (full sync) as subsequent syncs are deltas. In any case, here’s a quick PowerShell script you can run against Azure AD that removes only those users that are synchronized with on-premises AD and are unlicensed: https://github.com/skaggej/powershell/blob/master/PS_Azure_AD_Remove_Synchronized_Unlicensed_Users.ps1.
It’s pretty self-explanatory, but feel free to leave comments/questions.