The wording is a bit confusing. Let's modify the punctuation a bit to show more clearly the intended meaning:
Holders of [certain visas] may enter and stay, or pass through the territory of Montenegro up to 30 days (and not longer than the expiry of visa if the period of validity of the visa is less than 30 days).
It simply means that you will be allowed to stay for fewer than 30 days if your Schengen visa expires before the end of the 30-day period. In other words, you must leave within 30 days or before your visa expires, whichever comes first.
Note that this does not actually implicate your 34-day duration of stay allowed by the visa; the period of validity is determined by the expiration date. Days spent in Montenegro do not count toward your 34-day total.