fork download
  1. # your code goes here
  2. for i in range(int(input())):
  3. string = input()
  4. stack = []
  5. count = 0
  6. sum = 0
  7. for exp in string:
  8. if exp == '<':
  9. stack.append(exp)
  10. elif exp == '>' and len(stack) > 0:
  11. count += 2
  12. stack.pop()
  13. else:
  14. count = 0
  15. break
  16. if len(stack) == 0:
  17. print(count)
  18. else:
  19. print(0)
Success #stdin #stdout 0.01s 27712KB
stdin
2
<><<>>
<<<<<<>>>>>><><><<>>
stdout
6
20