The farmer has 51+5 = <<51+5=56>>56 cows in its herd.
The farmer sells 56/4 = <<56/4=14>>14 cows of the herd.
The farmer now has 56-14 = <<56-14=42>>42 cows.
#### 42