Nothing wrong in the code. I tested it. When you run it as is it would, most probably, 111111.
The cloning in the makeCalendar function
works asynchronously and you need to provide a wait block or any other task that would allow the cloning process to finish and then try to count the number of buttons.
I added 1 sec wait and the process worked successfully.