So we are starting out with 30 messages.
If 1/5 of the messages Lily receives are picture messages, then take 1/5 x 30 to find out how many that is.
1/5 x 30 = 30/5 = 6. So Lily receives 6 picture messages.
If 7/8 of the remaining messages are texts, then we need to find the number of remaining messages. If 6 are pictures and she receives 30 overall, then 30 - 6 = 24, the remaining number of messages. Since we know 7/8 of this number is the number of texts Lily received, let's do some more multiplication:
7/8 x 24 = (7 x 24)/8 = 168/8 = 21.
So Lily received 21 text messages, 6 picture messages, and 3 of something else!