Black hole microstate counting from the gravitational path integral