There are 800 x 5/8 = <<800*5/8=500>>500 girls.
So, there are 800 - 500 = <<800-500=300>>300 boys.
There are 500 x 7/10 = <<500*7/10=350>>350 girls that are in the primary grades.
Hence, 500 - 350 = <<500-350=150>>150 girls are middle schoolers.
There are 300 x 2/5 = <<300*2/5=120>>120 boys that are in the primary grades.
Hence, 300 - 120 = <<300-120=180>>180 boy students are middle schoolers.
Therefore, a total of 150 girls + 180 boys = <<150+180=330>>330 middle schoolers.
#### 330