In a recent science class, 6 students recorded the number of pets they own. The results are as follows: 1, 2, 1, 3, 2, and 4. What is the median number of pets owned by the students?