The least amount that's necessary to prevent detonation (spark knock). On most vehicles, that's 87 octane regular grade, unleaded gasoline. But on higher compression engines, or turbocharged or supercharged engines, the engine may require premium grade 91 to 93 octane fuel.
Detonation, which can be very damaging to your engine, occurs when the octane rating of the fuel isn't high enough to handle the heat and pressure. Instead of a single flame front forming when the fuel is ignited, multiple flame fronts form spontaneously throughout the combustion chamber. When these collide, the shock waves make a pinging noise, and the piston receives a hammer-like blow.
(More information about detonation is available.)
One way to prevent detonation is to use a higher octane fuel. The octane rating of a motor fuel is a measure of its detonation resistance. The octane that's posted on the filling station pump is "pump octane," which is an average of something called "research" and "motor" octane ratings (which are two different laboratory methods of measuring octane). The higher the pump octane number, the better able the fuel is to resist detonation.
A gasoline's octane rating depends on the blend of hydrocarbons in the fuel and other ingredients that are added to it. Tetraethyl lead was long used as an anti-knock additive to improve gasoline octane. In fact, it was the most effective and least expensive octane-boosting additive that could be used for this purpose. But leaded fuel cannot be used in a vehicle with a catalytic converter because the lead fouls the catalyst. So unleaded fuel must contain other octane-boosting additives such as MBTE or alcohol.
Most unleaded gasoline today is rated at 87 octane, which is sufficient for engines with compression ratios of up to about 9 to 1. Higher compression engines, engines with turbochargers or superchargers, or ones used frequently for towing should use a higher grade or premium gasoline.
CAUTION: Follow the fuel recommendations in your vehicle owner's manual. If your vehicle requires premium 91 or higher octane fuel, then you must use premium.
If you can't find pump gas with a high enough octane to prevent detonation, you can always add an aftermarket octane boosting fuel additive to your fuel tank. Such products can boost the octane rating of ordinary pump gas several points depending on the concentration used (always follow directions). But even this might not be enough to eliminate a persistent spark knock if your engine has an underlying problem.