The point here is that when the file is uploaded, firstly the ItemAdding event will be raised, and only after that the page where you can change properties and press the Save button will be shown.
So after item is added and page is shown to the end user, your code in ItemAdded will be executed, and it will change the same item which user is trying to edit. Hence, it is not a surprise to get the "Item has been modified" exception.
I'd recommend you to use ItemUpdating event receiver instead of ItemAdded. You should be able retrieve the downloaded file using the following code:
SPFile file = web.GetFile(properties.AfterUrl);
Then, you can set the "Number of pages" column value using AfterProperties collection, if it is not initialized yet (you can check this in BeforeProperties).
So the final code will look something like this:
if (String.IsNullOrEmpty(properties.BeforeProperties[numberOfPagesFieldInternalName]))
{
SPFile file = web.GetFile(properties.AfterUrl);
var numberOfPages = /* count the number of pages */;
properties.AfterProperties[numberOfPagesFieldInternalName] = numberOfPages.ToString();
}