In a survey, 50 students were asked about their preferences for two ice cream flavors: chocolate and vanilla. 30% of the students preferred chocolate, 40% preferred vanilla, and the rest liked both flavors. How many students liked both flavors? Let's think step by step and output the final answer within \boxed{}.
user