Paint The Tiles

  • + 0 comments
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int N = in.nextInt();
        String C = in.next();
    
        char[] arr = new char[N];
        arr = C.toCharArray();
        int count = 1;
        for(int i=0; i<N-1; i++)
        {
            if(arr[i] != arr[i+1])
                count++;
    
        }
        System.out.println(count);
    }