Because there are more rasters than classifications, it would be expedient to use procedures that handle the rasters as a group rather than having to process them one by one. A built-in command, Less than Frequency, exists to do precisely that:
The number of rasters classified as "K" is the number less than 2, given with an expression like
Q2 = LessThanFrequency(2, ["Input raster 1", "Input raster 2", ..., "Input raster 8"])
Of course the "..." has to be replaced by explicit mentions of the other rasters. However, the order in which the rasters are named does not matter.
The number of rasters classified as "K" or "V" is the number less than 5, given with an expression like
Q5 = LessThanFrequency(5, ["Input raster 1", "Input raster 2", ..., "Input raster 8"])
Notice that this is achieved with a simple cut-and-paste of the expression for "Q2", changing the "2" to a "5".
The number of rasters classified as "K" or "V" or "Z" should not be assumed to equal 8 (unless you are absolutely sure there are no NoData cells and all values truly are less than 12). Instead, keep up the preceding pattern. Since the help page examples indicate LessThanFrequency
uses a strict comparison--equalities are not included--consider making a comparison with a threshold slightly greater than 12, as in
Q13 = LessThanFrequency(13, ["Input raster 1", "Input raster 2", ..., "Input raster 8"])
After these three calculations you can obtain the individual class counts via subtraction, as in
V = "Q5" - "Q2"
Z = "Q13" - "Q5"
K
, of course, is simply "Q2" (provided you are sure the input values are always 1 or greater and never lie between 1.5 and 2).
Looking back, it is evident that in general you can count m interval-based classes in a set of m rasters by means of m applications of LessThanFrequency
followed by m-1 differences. When n is larger than 2 * m, this will be one of the most efficient methods you can apply. In any case it is very clear procedure, easy to write and easy to verify.