Buggy python submission (verdict: Runtime Error):
# coding: utf-8
 
# R: Right hand side
# L: Left  hand side
def add_stone(stone, pos, searched_stones):
    sample = searched_stones[::[1, -1][pos == "R"]]
    if sample[0] == stone:
        return None
 
    for n, s in enumerate(sample[1:]):
        if s == stone:
            return stone * (n + 2) + sample[1 + n:]
 
 
def stones_bfs(searched_stones):
    
    queue = [searched_stones + "0"]
    patterns = [["B", "R"], ["B", "L"], ["W", "R"], ["W", "L"]]
    
    while queue:
        stones = queue.pop(0)
        if (stones.count("W") == len(stones) - 1 |
            stones.count("B") == len(stones) - 1):
            return int(stones[-1])
            
        for p in patterns:
            s = add_stone(*p, stones[:-1])
            if s is not None:
                queue += [s + str(int(stones[-1]) + 1)]
 
print(stones_bfs(input().strip()))

Fixed submission:
# coding: utf-8

stones = input().strip()
counter, switch = 0, stones[0]

for s in stones[1:]:
    if switch != s:
        switch = s
        counter += 1

print(counter)

Buggy python submission (verdict: Runtime Error):
# coding: utf-8
 
# R: Right hand side
# L: Left  hand side
def add_stone(stone, pos, searched_stones):
    sample = searched_stones[::[1, -1][pos == "R"]]
    if sample[0] == stone:
        return None
 
    for n, s in enumerate(sample[1:]):
        if s == stone:
            return (stone * (n + 2) + sample[1 + n:])[::[1, -1][pos == "R"]]
 
 
def stones_bfs(searched_stones):
    
    queue = [searched_stones + "0"]
    patterns = [["B", "R"], ["B", "L"], ["W", "R"], ["W", "L"]]
    
    while queue:
        stones = queue.pop(0)
        if (stones.count("W") == len(stones) - 1 |
            stones.count("B") == len(stones) - 1):
            return int(stones[-1])
            
        for p in patterns:
            s = add_stone(*p, stones[:-1])
            if s is not None:
                queue += [s + str(int(stones[-1]) + 1)]
 
print(stones_bfs(input().strip()))

Fixed submission:
# coding: utf-8

stones = input().strip()
counter, switch = 0, stones[0]

for s in stones[1:]:
    if switch != s:
        switch = s
        counter += 1

print(counter)

Buggy python submission (verdict: Runtime Error):
# coding: utf-8


# R: Right hand side
# L: Left  hand side
def add_stone(stone, pos, searched_stones):
    sample = searched_stones[::[1, -1][pos == "R"]]
    if sample[0] == stone:
        return None

    for n, s in enumerate(sample[1:]):
        if s == stone:
            return (stone * (n + 2) + sample[1 + n:])[::[1, -1][pos == "R"]]


def stones_bfs(searched_stones):
    
    queue = [[searched_stones, 0]]
    patterns = [["B", "R"], ["B", "L"], ["W", "R"], ["W", "L"]]
    
    while queue:
        stones = queue.pop(0)
        if (stones[0].count("W") == len(stones[0]) |
            stones[0].count("B") == len(stones[0])):
            return stones[-1]
            
        for p in patterns:
            s = add_stone(*p, stones[0])
            if s is not None:
                queue += [[s, stones[-1] + 1]]

print(stones_bfs(input().strip()))

Fixed submission:
# coding: utf-8

stones = input().strip()
counter, switch = 0, stones[0]

for s in stones[1:]:
    if switch != s:
        switch = s
        counter += 1

print(counter)