You will be given a definition of a task first, then some input of the task.
Given a passage and a query based on the passage, generate an unambiguous, concise and simple answer to the query from information in the passage. Note that the answer may not be present in exact form.

Becoming a doctor isn't a quick process. It starts with a four-year undergraduate degree, and continues with four more years in a medical or osteopathic medical school. After graduation, ... Certification is not required for physicians and surgeons; however, it may increase their employment opportunities. M.D.s and D.O.s seeking board certification in a specialty may spend up to 7 years in residency training; the length of time varies with the specialty. That residency, which typically involves grueling 80-hour workweeks, is required even if a doctor previously did a residency in a country with an advanced medical system, like Britain or Japan. The only exception is for doctors who did their residencies in Canada. The following specialists are some of the most common examples: 1 Allergists (specialists in diagnosing and treating hay fever or other allergies) 2 Cardiologists (heart specialists) 3 Dermatologists (skin specialists) 4 Gastroenterologists (digestive system specialists) 5 Ophthalmologists (eye specialists) A residency is like a job, and the resident generally works normal hours depending on the particular setting, gets a salary or stipend, has holidays and personal time off, and benefits like health insurance. So again, internship is simply the first year of residency. Residency can be anywhere from 2 more to 6 more years, depending on the specialty you choose. Many super-specialties have further training after residency, called fellowship - these can be 1 to 3 years in length. The link(s) below go to OES data maps for employment and wages by state and area. 1 Anesthesiologists. 2 Family and general practitioners. 3 Internists, general. 4 Obstetricians and gynecologists. 5 Pediatricians, general. 6 Physicians and surgeons, all other. 7 Psychiatrists. 8 Surgeons. How Long Does Medical Residency Training Last? Medical residency is a minimum of three years for primary care physicians and some other specialties, up to five years for some surgical specialties. (Some medical specialties require additional years of fellowship training in addition to the three to five years of residency training.) General Internists serve as primary care physicians, along with family medicine doctors and pediatricians. The biggest difference between Family Medicine and Internal Medicine is that IM training focuses on adults, with residents spending time between various adult medicine subspecialties. What We Do. The AMA is leading meaningful innovation to enable a better health care system for patients, physicians and the country. Query: how long does a doctor do a residency
Output:
Medical residency is a minimum of three years for primary care physicians and some other specialties, up to five years for some surgical specialties.