A poultry farm has only chickens and pigs. When the manager of the poultry counted the heads of the stock in the farm, the number totaled up to 200. However, when the number of legs was counted, the number totaled up to 540. How many chickens were there in the farm?