I think that if you were applying to only IM prelim programs, 5-6 would be MORE than enough. Candidates who match into ophtho are almost automatic for many preliminary spots which are in general not competitive.
If you are a VERY strong candidate and only applying to popular TY's (referring to the programs with a mixture of medicine, surgery and ample electives), 5-6 sounds reasonable. The popular TY programs have a lot of good applicants from derm, rads, anesth, etc all competing for them, so they can be even harder to get than an ophtho position, so if you have your heart set on that type of intern year, >6 would be more safe.
Most people interview at several great TY's and then for safety reasons interview at some prelim medicine programs that are in geographic locations that would be nice for them (like your home instition, your home town, or the place you're doing ophtho). In the end, a lot of people end up choosing a prelim medicine year over a TY for location reasons.
The good news is that if you match into ophtho, in the end you'll be ok. If you go unmatched for your intern year, there are ample un-filled positions you can scramble into (prelim medicine or prelim surgery). This is obviously not ideal, but it may be a comforting thought.