def find_balance_index(source, start='<STR_LIT:{>', end='<STR_LIT:}>'):
state = <NUM_LIT:1><EOL>for index, char in enumerate(source):<EOL><INDENT>if char == start:<EOL><INDENT>state += <NUM_LIT:1><EOL><DEDENT>elif char == end:<EOL><INDENT>state -= <NUM_LIT:1><EOL><DEDENT>if state == <NUM_LIT:0>:<EOL><INDENT>return index<EOL><DEDENT><DEDENT>raise RuntimeError('<STR_LIT>')<EOL>
Get the first balance index.