Generalized cohomology of M2/M5-branes