automatic number of label detection