22. The Unfortunate Grocer. A grocer, the owner of a small shop, decided to set aside a small amount of money - all in dollar bills and coins of fifty cents and twenty-five cents. He distributed the entire amount into 8 bags, so that in each bag there was the same number of dollar bills and coins of each denomination. One evening, the grocer decided to redistribute all this money into 7 bags so that the number of dollar bills and coins of each denomination remained equal in all bags. The next evening, he similarly redistributed all the money into 6 bags.

Then the unfortunate madman tried to redistribute everything into 5 bags, but after hours of hard work, he died in complete exhaustion, bitterly mourned by his neighbors. What is the smallest amount of money that the grocer could have set aside for a rainy day?