Cognitive Cost of Flocking: A Geometric and Hamiltonian Perspective