Okay, so the total cookies is given by 22 cookies (the ones given to the students) plus 27 cookies (the ones left over) Therefore there were 49 cookies in total. Subtract the 24 cookies from the first batch, and you have 25 cookies remaining, which is the total from the second batch.
25 cookies.