import random as r
out=''
file=open(input('.mm: ')+'.mm','r').readlines();import time;import os;cls=lambda:os.system('cls'if os.name in ('nt','dos')else'clear');row=0;column=0;pointer='';directions=['up','down','left','right'];direction='down';stack=[0]
def move(d):
    global row, column
    if d=='down':row+=1
    if d=='left':column-=1
    if d=='right':column+=1
def process(d):
    global row, column, direction, stack, out
    #print(str(column)+', '+str(row))
    #print(stack)
    #print(out)
    try:
        pointer=file[row][column]
        direction='down'
        if pointer=='\\':
            if direction=='down':
                direction='right'
        if pointer=='/':
            if direction=='down':
                direction='left'
        if pointer in '0123456789':
            stack+=[int(pointer)]
        if pointer=='#':
            stack+=[int(input('> '))]
        if pointer=='?':
            stack+=[ord(input('> '))]
        if pointer=='g':
            if stack[-1]>stack[-2]:
                stack+=[True]
            else: stack+=[False]
        if pointer=='{':
            if stack[-1]==True:
                direction='left'
            else: direction='right'
        if pointer=='}':
            if stack[-1]==True:
                direction='right'
            else: direction='left'
        if pointer=='~':
            stack=stack[:-1]
        if pointer=='.':
            print(stack[-1])
        if pointer=='&':
            stack[-1],stack[-2]=stack[-2],stack[-1]
        if pointer=='+':
            stack+=[stack[-2]+stack[-1]]
        if pointer=='-':
            stack+=[stack[-2]-stack[-1]]
        if pointer=='*':
            stack+=[stack[-2]*stack[-1]]
        if pointer=='`':
            stack+=[stack[-2]/stack[-1]]
        if pointer=='x':
            while not file[row][column]=='o':
                row-=1
            return
        if pointer==',':
            out+=chr(stack[-1])
        if pointer=='!':
            time.sleep(9999*9998*9997);exit()
        if pointer=='"':
            move(direction)
            stack+=[ord(file[row][column])]
        if pointer=='p':
            print(out)
            out=''
        if pointer=="'":
            stack+=(ord(x) for x in str(stack[-1]))
    except:
        exit()
    move(direction)
cls()
while True:
    process('down')
print(out)