def search_insert(nums, target):  
    left, right = 0, len(nums) - 1  
    
    while left <= right:  
        mid = (left + right) // 2  
        
        if nums[mid] == target:  
            return mid  # Target found  
        elif nums[mid] < target:  
            left = mid + 1  # Target is in the right half  
        else:  
            right = mid - 1  # Target is in the left half  
            
    return left  # Return the position to insert the target  

# إدخال قائمة الأعداد والعدد المستهدف من المستخدم  
user_input = input("Enter the sorted list of unique integers (comma-separated): ")  
nums = [int(num) for num in user_input.split(",")]  
target = int(input("Enter the target number: "))  

# حساب الناتج  
position = search_insert(nums, target)  
print(f"The position for the target {target} is: {position}")