import functools


def get_color_count(img, color_palette):
    """ Returns the number of colors found in the color palette

    Parameters: 
        img (image)     -- Pillow image

    Returns:
        colors (list(int, (int,int,int)))   -- list of colors as a tuple and the number of occurrences of the color
        count (int)                         -- number of colors in the image that are found in the color palette
   
    """
    w, h = img.size
    # get all unique colors in image and their count 
    colors = img.getcolors(maxcolors=w * h)

    # count how many of the colors are in the nes palette
    return colors, functools.reduce(lambda x, y: (x + (1 if y[1] in color_palette else 0)), colors, 0)