Two barrels X and Y contained different amounts of oil at first. Some oil from X was poured to Y so that the amonut of oil in Y was doubled. Then, some oil from Y was poured to X so that the amount of oil in X was doubled. After these two pourings, the barrels each contained 18 litres of oil. How many litres of oil were in X at first?