Fix batch pages count calculation (#5211)