For stainless, the first three (or four for alloy steels) are typicially the AISI/SAE designation, with the last two (or one) being use to denote a certain temper, or processing method, or a chemistry modification of the "standard" grade. At the present time, there is no real convention on what the last numbers should be (at least not that I'm aware of).
In general (from MatWeb):
Overview of the UNS system
This is an overview of the UNS system, with special emphasis on common commercial alloys. As with any system, there are ambiguities such as the distinction between a nickel-based superalloy and a high-nickel stainless steel.
Axxxxx - Aluminum Alloys
Cxxxxx - Copper Alloys, including Brass and Bronze
Fxxxxx - Iron, including Ductile Irons and Cast Irons
Gxxxxx - Carbon and Alloy Steels
Hxxxxx - Steels - AISI H Steels
Jxxxxx - Steels - Cast
Kxxxxx - Steels, including Maraging, Stainless, HSLA, Iron-Base Superalloys
L5xxxx - Lead Alloys, including Babbit Alloys and Solders
M1xxxx - Magnesium Alloys
Nxxxxx - Nickel Alloys
Rxxxxx - Refractory Alloys
R03xxx- Molybdenum Alloys
R04xxx- Niobium (Columbium) Alloys
R05xxx- Tantalum Alloys
R3xxxx- Cobalt Alloys
R5xxxx- Titanium Alloys
R6xxxx- Zirconium Alloys
Sxxxxx - Stainless Steels, including Precipitation Hardening and Iron-Based Superalloys
Txxxxx - Tool Steels
Zxxxxx - Zinc Alloys