Calculate Substantial Presence Test