Optimize robot count calculation