n = int(input()) s = input().strip() if n == 0: print(0) exit() # Split the string into runs of the same color runs = [] prev = s[0] runs.append(prev) for c in s[1:]: if c != prev: runs.append(c) prev = c count = len(runs) # If the first and last runs are the same, subtract one if len(runs) > 1 and runs[0] == runs[-1]: count -= 1 print(count)