
def check_balance(expression):
  stack = []
  for i, c in enumerate(expression):
    if c in '({':
      stack.append(c)
    elif c in '})':
      if not stack: 
        return i
      ob = stack.pop()
      if (ob == '(' and c != ')') or (ob == '{' and c != '}'):
        return i
  return len(expression) if stack else -1


a4c3474aab0d547f6c91ad4e6bdf3b7ee8fb7c67
<mask token>

def check_balance(expression):
    stack = []
    for i, c in enumerate(expression):
        if c in '({':
            stack.append(c)
        elif c in '})':
            if not stack:
                return i
            ob = stack.pop()
            if ob == '(' and c != ')' or ob == '{' and c != '}':
                return i
    return len(expression) if stack else -1


def check_balance(expression):
  stack = []
  for i, c in enumerate(expression):
    if c in '({':
      stack.append(c)
    elif c in '})':
      if not stack: 
        return i
      ob = stack.pop()
      if (ob == '(' and c != ')') or (ob == '{' and c != '}'):
        return i
  return len(expression) if stack else -1

