Calculate number of bytes to write based on the formula