Mrs. Frisby is the widowed head of a family of field mice. Mrs. Frisby's son, Timothy, is ill with pneumonia just as the farmer Mr. Fitzgibbon begins preparation for spring plowing in the garden where the Frisby family lives. Normally she would move her family, but Timothy would not survive the cold trip to their summer home. Mrs. Frisby obtains medicine from her friend Mr. Ages, an older white mouse. On the return journey, she saves the life of Jeremy, a young crow, from Dragon, the farmer's cat - the same cat who had killed her husband, Jonathan. Jeremy suggests she seek help in moving Timothy from an owl who dwells in the forest. Jeremy flies Mrs. Frisby to the owl's tree, but the owl says he can't help until he finds out that she is the widow of Jonathan Frisby. He suggests that Mrs. Frisby seek help from the rats who live in a rosebush near her.
Mrs. Frisby discovers the rats have a literate and mechanized society. They have technology such as elevators, have tapped the electricity grid to provide lighting and heating, and have acquired other human skills, such as storing food for the winter. Their leader, Nicodemus, tells Mrs. Frisby of the rats' capture by scientists working for a laboratory located at the National Institute of Mental Health (NIMH) and the subsequent experiments that the humans performed on the rats, which increased the rats' intelligence to the point of being able to read, write, and operate complicated machines, as well as enhancing their longevity and strength. This increased intelligence and strength allowed them to escape from the NIMH laboratories and migrate to their present location. Jonathan Frisby and Mr. Ages were the only two survivors of a group of eight mice who had been part of the experiments at NIMH, and made the rats' escape possible. Out of respect for Jonathan, the rats agree to move Mrs. Frisby's house to a location safe from the plow.
Nicodemus also tells Mrs. Frisby about "The Plan", which is to abandon their lifestyle of dependence on humans, which some rats regard as theft, for a new, independent farming colony. One rat, Jenner, disagreed vehemently with The Plan and left the colony with a group of followers at some point prior to Mrs. Frisby's arrival.
To move the Frisby home, the rats have to drug Dragon as it is too dangerous to work in the open without any place to hide. However, Mr. Ages has a broken leg and cannot dash to Dragon's bowl to put in the drug. Since the other rats are too big to fit into the hole in the wall to enter the house, Mrs. Frisby volunteers to go. Unfortunately, she is caught by the family's son, Billy, who puts her in a cage. While captured, Mrs. Frisby overhears the Fitzgibbons discussing an incident at a nearby hardware store in which a group of rats were electrocuted after seemingly attempting to steal a small motor. This has attracted the attention of a group of men (who never identify themselves) who have offered to exterminate the rat colony on Fitzgibbon's land free of charge for him.
At night, Justin (one of the rats) comes to save Mrs. Frisby and manages to get her out of the cage. Mrs. Frisby warns Justin of what she learned while captured; they assume that the rats at the hardware store were all from Jenner's group and that the group of men were from NIMH and are looking for them specifically.
The successful house move allows the mouse family to remain while Timothy recovers before moving to their summer home. Although the rats have not yet had time to move everything they needed for The Plan, they manage to destroy their underground rooms, and create the illusion that they are just regular rats by placing rubbish in the remaining rooms. As the others move, ten rats stay behind so the exterminators would not think the rat hole has been abandoned. When the exterminators fill the rat hole with poisonous gas, eight of the ten rats manage to escape, while two rats die in the hole. It is not revealed exactly who these two are.
Once Timothy recovers, Mrs. Frisby and her family move to their summer home, and Martin makes plans to visit the rats when they return to their winter home again.
Output: How many rats escape the gases?