> cell 0 is reserved > cell 1 is reserved for count , the first character# ASCII digit [ >, read character [ swap this cell with its next cell - > + < ] after this swap# original cell value should be 0 > move to the next cell ---------- decrease 10# '\n' in brainfuck is 10 (in most case) [ if the cell is not 0 ++++++++++ increase 10# reset its original value < move to the original cell + increase 1 manually# just for while loop > move to the next cell - decrease 1# because we just add 1 to original cell [ loop until the next cell is 0 < + > - ] after this while loop# we reset the original cell to its original value ] < but the ptr points to the next cell# we should move it to its left cell ] < read completed# we are going to move to the count cell# 1 [ < ] > now move ptr to cell 2# the start of the string [ cut the value of cell2# paste to cell 1 and cell 0 - < + < + >> ] after the while statement# ptr points to cell 2 < < move ptr to cell 0 and restore cell 2# because cell 2 is start of the string [ - > > + < < ] ptr points to cell 0 after while loop > move it to cell 1 convert ASCII code to integer# cell 1 is used for count ------------------------ ------------------------ start print [ > move to cell 2# the start of the string [ while cell has value# print it . > ] the cell after the last cell of the string we use it for printing '\n' ++++++++++ . ---------- < goto cell 0 [ < ] > move to cell 1# count - decrease count ]