#P2530. Minimize Boxing Operations

    ID: 15800 Type: Default 1000ms 256MiB

Minimize Boxing Operations

Minimize Boxing Operations

Factory 118 is the world’s only secret facility that refines the element known as KIE. Due to the difficulty of the refining process, the plant produces products with three distinct purity levels:

  • $A$: $100\%$
  • $B$: $1\%$
  • $C$: $0.01\%$

For sale purposes, products of different purities must be boxed separately. The process is as follows:

  1. Initially, the worker Grant picks the first 10 products from the assembly line (or all remaining if there are less than 10).
  2. In each subsequent operation, he chooses one purity type from the products currently in his hand and boxes all products of that purity.
  3. Then, he replenishes his hand by taking products in order from the assembly line until his hand holds 10 items (or he takes all if fewer remain).
  4. The process stops when all products have been boxed.

Your task is to help Grant complete his work with the minimum number of boxing operations.

inputFormat

The first line contains an integer $n$ ($1 \le n \le 10^5$), the total number of products.

The second line contains a string of length $n$ consisting only of the characters 'A', 'B', and 'C', which indicate the purity of each product as they appear on the assembly line.

outputFormat

Output a single integer representing the minimum number of boxing operations required for Grant to box all products.

sample

10
AAAAAAAAAA
1