def rgb_to_grayscale(img):
    """
    Returns greyscale image
    Parameters
    ----------
    img: PIL Image
    Returns
    -------
    PIL Image:
        image converted to greyscale
    """
    width, height = img.size
    res = img.copy()
    for i in range(width):
        for j in range(height):
            (r, g, b) = img.getpixel((i, j))
            gs = int((r + g + b) / 3)
            res.putpixel((i, j), (gs, gs, gs))
    return res