shaving the head after Hajj or Umrah

Is it obligatory to shave all the hair of the head after performing Hajj or Umrah, or a part of the hair can be cut?

It is not obligatory to shave one’s head or to cut all his hair at the conclusion of Ihram in Umrah or Hajj. One can also cut his hair instead of shaving it. The minimum requirement for coming out of ihram, according to fiqh-e-Hanafi, is to cut one’s hair at least to the measure of a fingertip from all sides of one’s hair. If one has cut his hair to this extent, he can come out of Ihram. However, if one’s hair are too short, and he cannot cut them to the measure of a fingertip, he will have to shave his head without which he cannot come out of Ihram.
It should, however, be remembered that shaving the head is more preferable and carries more thawab. It is reported by a number of authorities that the Holy Prophet (Sallaho Alaihai Wasallam) has prayed to Allah thrice for bestowing his mercy on those who shave their hands after performing Hajj, while he prayed only once for those who cut their hair.

Fatawa by Mufti Muhammad Taqi Usmani.