When the grain in warehouse A is twice that in warehouse B, warehouse B will have grain:
277/( 1+2)=277/3 (ton)
B input: 277/3-87= 16/3 (ton)
Delivery by Party A: 60- 16/3= 164/3 (ton)