With OTB 7.4, I use keywordlist.GetSize(). It is not possible with OTB 8.0 and ImageMetadata since it doens't have such a function.
keywordlist.GetSize()