if you are doing a ul li list then you could count the max by finding occurence of the ul's children by using
$('ul').children().length;
I have implemented a jsfiddle where this would work here:
I have made it so that every time the right button is pressed the value is parsed so that it is recognised as an integer. Then there is an if which makes sure that this value does not exceed the maximum number of children in the list.
(I've just replaced the jsfiddle with a second version which includes a left button example because I noticed that on your site it also allows you to go into negative values).