prints correct number of stack elements