Apple sells fewer phones but profits rise