#include <iostream>
using namespace std;
int main() {
int n; // Количество ячеек
cin >> n;
string tape(n,0);
int pointer = 0;
string program;
cin >> program;
cout << program << endl;
for (unsigned int i = 0; i < program.length(); i++) {
if (program[i] == '>')
pointer++;
if (program[i] == '<')
pointer--;
if (program[i] == '+')
tape[pointer]++;
if (program[i] == '-')
tape[pointer]--;
if (program[i] == '.')
cout << tape[pointer];
if (program[i] == ',')
cin >> tape[pointer];
if (program[i] == '[') {
if (tape[pointer] == 0) {
int counter = 1;
while (counter > 0) {
i++;
if (program[i] == '[')
counter++;
if (program[i] == ']')
counter--;
}
}
}
else if (program[i] == ']') {
if (tape[pointer] != 0) {
int counter = 1;
while (counter > 0) {
i--;
if (program[i] == '[')
counter--;
if (program[i] == ']')
counter++;
}
}
}
}
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKaW50IG1haW4oKSB7CglpbnQgbjsgLy8g0JrQvtC70LjRh9C10YHRgtCy0L4g0Y/Rh9C10LXQugoJY2luID4+IG47CglzdHJpbmcgdGFwZShuLDApOwoJaW50IHBvaW50ZXIgPSAwOwoJc3RyaW5nIHByb2dyYW07CgljaW4gPj4gcHJvZ3JhbTsKCWNvdXQgPDwgcHJvZ3JhbSA8PCBlbmRsOwoJZm9yICh1bnNpZ25lZCBpbnQgaSA9IDA7IGkgPCBwcm9ncmFtLmxlbmd0aCgpOyBpKyspIHsKCQlpZiAocHJvZ3JhbVtpXSA9PSAnPicpCgkJCXBvaW50ZXIrKzsKCQkKCQlpZiAocHJvZ3JhbVtpXSA9PSAnPCcpCgkJCXBvaW50ZXItLTsKCQkKCQlpZiAocHJvZ3JhbVtpXSA9PSAnKycpCgkJCXRhcGVbcG9pbnRlcl0rKzsKCQkKCQlpZiAocHJvZ3JhbVtpXSA9PSAnLScpCgkJCXRhcGVbcG9pbnRlcl0tLTsKCQkKCQlpZiAocHJvZ3JhbVtpXSA9PSAnLicpCgkJCWNvdXQgPDwgdGFwZVtwb2ludGVyXTsKCQkKCQlpZiAocHJvZ3JhbVtpXSA9PSAnLCcpCgkJCWNpbiA+PiB0YXBlW3BvaW50ZXJdOwoJCQoJCWlmIChwcm9ncmFtW2ldID09ICdbJykgewoJCQlpZiAodGFwZVtwb2ludGVyXSA9PSAwKSB7CgkJCQlpbnQgY291bnRlciA9IDE7CgkJCQl3aGlsZSAoY291bnRlciA+IDApIHsKCQkJCQlpKys7CgkJCQkJaWYgKHByb2dyYW1baV0gPT0gJ1snKQoJCQkJCQljb3VudGVyKys7CgkJCQkJaWYgKHByb2dyYW1baV0gPT0gJ10nKQoJCQkJCQljb3VudGVyLS07CgkJCQl9CgkJCX0KICAgICAgICB9CiAgICAgICAgZWxzZSBpZiAocHJvZ3JhbVtpXSA9PSAnXScpIHsKCQkJaWYgKHRhcGVbcG9pbnRlcl0gIT0gMCkgewoJCQkJaW50IGNvdW50ZXIgPSAxOwoJCQkJd2hpbGUgKGNvdW50ZXIgPiAwKSB7CgkJCQkJaS0tOwoJCQkJCWlmIChwcm9ncmFtW2ldID09ICdbJykKCQkJCQkJY291bnRlci0tOwoJCQkJCWlmIChwcm9ncmFtW2ldID09ICddJykKCQkJCQkJY291bnRlcisrOwoJCQkJfQoJCQl9CiAgICAgICAgfQogICAgfQoKCXJldHVybiAwOwp9
MTAwCisrKysrKysrKytbJmd0OysrKysrKysmZ3Q7KysrKysrKysrKyZndDsrKysmZ3Q7KyZsdDsmbHQ7Jmx0OyZsdDstXSZndDsrKy4mZ3Q7Ky4rKysrKysrLi4rKysuJmd0OysrLiZsdDsmbHQ7KysrKysrKysrKysrKysrLiZndDsuKysrLi0tLS0tLS4tLS0tLS0tLS4mZ3Q7Ky4mZ3Q7Lg==
100
++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.>.