from itertools import permutations
from bisect import bisect


class Card:
    suit: str
    number: int

    def __init__(self, S: str):
        assert S[0] in set("SWERC")
        self.suit = S[0]
        self.number = int(S[1:])
        assert 1 <= self.number <= N

    def convert_to_number(self, order_on_suit):
        return self.number - 1 + N * order_on_suit[self.suit]


def length_longuest_increasing_sequence(l):
    end_lis = []
    for value in l:
        pos = bisect(end_lis, value)
        if pos == len(end_lis):
            end_lis.append(value)
        else:
            end_lis[pos] = value
    return len(end_lis)


# Parse input
N = int(input())
assert 1 <= N <= 100000

hand = [Card(s) for s in input().split()]
assert len(hand) == N

min_moves = N
for perm_on_suit in permutations(list("SWER")):
    order_on_suit = {suit: i for i, suit in enumerate(perm_on_suit)}
    order_on_suit["C"] = 4 # trump card is always last
    ordered_hand = [card.convert_to_number(order_on_suit) for card in hand]
    lis = length_longuest_increasing_sequence(ordered_hand)
    if N - lis < min_moves:
        min_moves = N - lis 

print(min_moves)
