There are X balls that look identical. All balls except one has the same weight. The different ball is either lighter or heavier than the others.
You have a balance scale with two plates and you can only use it to compare the weights of the balls. With each use you can put any number of balls in each plate and as a result find out which side is heavier or if the two sides have the same weight.
You can guarantee finding the different ball and whether it is lighter or heavier by using the scale at most 4 times. What is the maximum possible X satisfying this condition?