Let x be the No of the heads of the horses.Then the No of the human heads are 12-x.
Then the no of the legs of the horses are :4x and the No of the human leg are:2(12-x).
Can you carry on from here??
There is another way of solving this problem out ,without using algebra and variables ,but by using simple arithmetic.
Suppose in the barn were only horses ,then the No of legs would be 12x4=48.But since the No of legs are 34,then the No of remaining legs 48-34= 14 are the human legs. Divide by 2 and you have the No of people in the barn