#BS0000002. Vị trí chèn (Search Insert Position)

Vị trí chèn (Search Insert Position)

Search Insert Position

Source: LeetCode

Version: Phuoc Hung OJ Extended

Problem Statement

Given nn distinct integers sorted increasingly and target, print its index if present. Otherwise print the index where it must be inserted so the array remains sorted. Equivalently, find the first ii with ai≥targeta_i\ge\text{target}; if none exists, answer nn. Required time: O(log⁡n)O(\log n).

Input

The first line contains nn and target. The second line contains nn distinct increasing integers.

Output

Print the position of target or its insertion position.

Subtasks

  • Subtask 1 — 20%: target lies outside [a0,an−1][a_0,a_{n-1}].
  • Subtask 2 — 30%: 1≤n≤10001\le n\le1000.
  • Subtask 3 — 50%: 1≤n≤1041\le n\le10^4, −104≤ai,target≤104-10^4\le a_i,\text{target}\le10^4.

Examples

Input

4 2
1 3 5 6

Output

1

Explanation

Inserting 2 at index 11 produces [1,2,3,5,6][1,2,3,5,6].