Mai distributed another group of flyers equally among the five volunteers. Then she remembered that she needed some flyers to give to teachers, so she took 2 flyers from each volunteer. Then, the volunteers had a total of 40 flyers to hang up.

If Mai distributed the flyers equally among the five volunteers, then each volunteer initially had 40/5 = 8 flyers.

After Mai took 2 flyers from each volunteer, the number of flyers each volunteer had left was 8 - 2 = 6 flyers.

Since each volunteer had 6 flyers left and there were 5 volunteers, the total number of flyers left is 6 * 5 = 30 flyers.

Therefore, Mai initially distributed 40 - 30 = 10 flyers to the teachers.