from collections import defaultdict, Counter
import sys
import json

brainFuck = str(sys.stdin.read())

valid = "><+-,.[]"

defs = json.load(open("defs.json"))
	
def parse(brainFuck):
	leftCounter = rightCounter = 0
	brackets = {}
	parsedInput = ''.join([char for char in brainFuck if char in valid])
	for key,char in enumerate(parsedInput):
		if char == "[":
			leftCounter += 1
			rightCounter = leftCounter
			brackets[key] = leftCounter
		elif char == "]":
			while rightCounter in [x for x, y in Counter(brackets.values()).items() if y > 1]:
				rightCounter -= 1
			brackets[key] = rightCounter
	bracketList = defaultdict(list)
	for k, v in brackets.items():
		bracketList[v].append(k)
	bracketList =  list(dict(bracketList).values())
	for subList in bracketList:
		subList.sort()
	return parsedInput, bracketList

def main(args):
	parsedInput = args[0]
	brackets = args[1]
	counter = tapeCounter = 0
	tape = [0]*30000
	while counter < len(parsedInput):
		char = parsedInput[counter]
		if char == ">":
			tapeCounter +=1
		elif char == "<":
			tapeCounter -=1
		elif char == "+":
			tape[tapeCounter] += 1
		elif char == "-":
			tape[tapeCounter] -= 1
		elif char == ",":
			tape[tapeCounter] = ord(input("Enter: ")[0])
		elif char == ".":
			print(chr(tape[tapeCounter]))
		elif char == "[" and tape[tapeCounter] == 0:		
			key = [y[0] for y in brackets].index(counter)
			counter = brackets[key][1]
			continue
		elif char == "]" and tape[tapeCounter] != 0:
			key = [y[1] for y in brackets].index(counter)
			counter = brackets[key][0]
			continue
		else:
			main(parse(defs[char]))
		counter+=1

main(parse(brainFuck))
from collections import defaultdict, Counter
import sys
import json

brainFuck = str(sys.stdin.read())

valid = "><+-,.[]"

defs = json.load(open("defs.json"))
	
def parse(brainFuck):
	leftCounter = rightCounter = 0
	brackets = {}
	parsedInput = ''.join([char for char in brainFuck if char in valid])
	for key,char in enumerate(parsedInput):
		if char == "[":
			leftCounter += 1
			rightCounter = leftCounter
			brackets[key] = leftCounter
		elif char == "]":
			while rightCounter in [x for x, y in Counter(brackets.values()).items() if y > 1]:
				rightCounter -= 1
			brackets[key] = rightCounter
	bracketList = defaultdict(list)
	for k, v in brackets.items():
		bracketList[v].append(k)
	bracketList =  list(dict(bracketList).values())
	for subList in bracketList:
		subList.sort()
	return parsedInput, bracketList

def main(args):
	parsedInput = args[0]
	brackets = args[1]
	counter = tapeCounter = 0
	tape = [0]*30000
	while counter < len(parsedInput):
		char = parsedInput[counter]
		if char == ">":
			tapeCounter +=1
		elif char == "<":
			tapeCounter -=1
		elif char == "+":
			tape[tapeCounter] += 1
		elif char == "-":
			tape[tapeCounter] -= 1
		elif char == ",":
			tape[tapeCounter] = ord(input("Enter: ")[0])
		elif char == ".":
			print(chr(tape[tapeCounter]))
		elif char == "[" and tape[tapeCounter] == 0:		
			key = [y[0] for y in brackets].index(counter)
			counter = brackets[key][1]
			continue
		elif char == "]" and tape[tapeCounter] != 0:
			key = [y[1] for y in brackets].index(counter)
			counter = brackets[key][0]
			continue
		else:
			main(parse(defs[char]))
		counter+=1

main(parse(brainFuck))