def f(nums): sortnums = sorted(nums) n = len(nums) i = nums.index(min(nums)) j = 0 if i == n - 1: return n - 1 while i < n and j < n: if nums[i] == sortnums[j]: i = i + 1 j = j + 1 else: i = i + 1 return n - j