Calculates pages length