Alex brought 48 cookies to school to celebrate his birthday. He gave 9 to teachers. He then shared equally the remaining cookies with his 18 classmates. How many cookies remained?