No, whats happening is whenever its upper, it is incrementing both the upper as well as the blank var. This is because there are two if blocks instead of one single connected if block.
Try
if upper then upper++ elsif lower then lower++ else blank++ endif; <-- That should handle any string that...