본문 바로가기

CodingTest/Baekjun Online Judge

[ BOJ / 파이썬 ] 3986 좋은 단어

/  제출 1  /

import sys
input = sys.stdin.readline


n = int(input())


answer = 0
for i in range(n):
  words = list(input().strip())
  stack = []

  for word in words:
    if not stack:
      stack.append(word)
    else:
      if stack[-1] == word:
        stack.pop()
      else:
        stack.append(word)
  
  if not stack:
    answer += 1

print(answer)