You can use findAll method from Sikuli Region class. The example code will look like this:
def returnImageCount(image):
count = 0
for i in findAll(image):
count += 1
return count
imageCount = returnImageCount(image)
if imageCount == 1:
click(buttonX.image)
elif imageCount == 2:
click(buttonY.image)
else:
pass