https://www.merriam-webster.com/words-at-play/why-y-is-sometimes-a-vowel-usage
Y is considered to be a vowel if…
The word has no other vowel: gym, my.
The letter is at the end of a word or syllable: candy, deny, bicycle, acrylic. TOASTY (TOAST AND THEN IT ENDS WITH AN "Y")
The letter is in the middle of a syllable: system, borborygmus.