If the number of grey birds is 40, there are 40+6 = <<40+6=46>>46 white birds near the cage.
When half of the grey birds fly away, the number that remains is 1/2*40 = <<1/2*40=20>>20
The total number of birds is 20+46 = <<20+46=66>>66 in and next to the cage.
#### 66