In a sorted array, the first index whose element is not less than the target, or the length if there is none. The upper bound is the first index whose element is greater than the target; their difference is the count of the target.