Dancing Queens

How many moves can the queens make?

Run 2

Input

_______Q
________
________
________
________
________
________
Q_______

Expected Output

40