public void solve() throws IOException {
    int n = nextInt();
    String input = nextToken();
    needref = new int[n][n];
    for (int x = 0; x < n; x++)
      for (int y = x + 1; y < n; y++)
        needref[x][y] = -1;
    int min = n;
    for (int x = 0; x < n - 1; x++) {
      int beg = x - 1;
      int end = x + 1;
      // System.out.println(x + " " + needed(input, beg, end) + " " +
      // needed(input, beg + 1, end));
      min = Math.min(min, needed(input, beg, end));
      if (input.charAt(x) == input.charAt(x + 1))
        min = Math.min(min, needed(input, beg + 1, end));
    }
    System.out.println(min);
  }