Page number calculation