While I did bother to do a lot of legwork and effort to determine which colors are maximally distant the issue of color blindness was always on my mind. While you can push the list of distinct colors to a couple dozens (read left to right, top to bottom).
It seems that given color blindness, you'd really be better off mixing in a few things other than just colors. While you could just use a static lookup list, which is likely the best for color distinction, you might want to consider if there's a better way to do that same thing with aspects that are more distinct to more people, like dashed lines, thicker lines, candicaned lines, marquee text made to fit a line, etc.
You get about four or five really distinct colors for those with lower gamuts of colors. And while my list is still really awesome. You might want to rethink your entire idea to use colors.