Problem: For a given array $a_1, a_2, a_3, ... , a_N$ of $N$ elements and an integer $K$, find the smallest sub-array size (smallest window length) where the elements in the sub-array contains all integers in range [$1, 2, ..., K$]. If there is no such sub-array, report 0.

Constraints

* $1 \leq N \leq 10^5$
* $1 \leq K \leq 10^5$
* $1 \leq a_i \leq 10^5$

Input

The input is given in the following format.

$N$ $K$
$a_1$ $a_2$ ... $a_N$

Output

Print the smallest sub-array size in a line.

Examples

Input

6 2
4 1 2 1 3 5


Output

2


Input

6 3
4 1 2 1 3 5


Output

3


Input

3 4
1 2 3


Output

0

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
#define inf (long long)1e9
using namespace std;

template <class T>
struct SegmentTree {
  // 1-indexed
  typedef function<T(T, T)> F;
  int n;
  F f;
  T unit;
  vector<T> dat;
  SegmentTree(){};
  SegmentTree(int newn, F f, T t) : f(f), unit(t) {
    init(newn);
  }
  void init(int newn) {
    n = 1;
    while(n < newn) n <<= 1;
    dat.assign(n << 1, unit);
  }

  // "go up" process
  void update(int k, T newdata) {
    dat[k += n] = newdata;
    while(k >>= 1) {
      dat[k] = f(dat[(k << 1) | 0], dat[(k << 1) | 1]);
    }
  }
  // [a,b)
  T query(int a, int b) {
    T vl = unit, vr = unit;
    for(int l = a + n, r = b + n; l < r; l >>= 1, r >>= 1) {
      if(l & 1) vl = f(vl, dat[l++]);
      if(r & 1) vr = f(dat[--r], vr);
    }
    return f(vl, vr);
  }
};

long long n, k;
vector<long long> a;

long long solve();

int main() {
  cin >> n >> k;
  a.resize(n);
  for(int i = 0; i < n; ++i) cin >> a[i];
  cout << solve() << endl;
  return 0;
}

long long solve() {
  long long ans = inf, l = 0, r = 0;
  auto f = [](long long l, long long r) {
    return min(l, r);
  };
  SegmentTree<long long> rmq(1000000, f, 1000000);
  for(int i = 0; i < 1000000; ++i) rmq.update(i, 0);
  for(l = 0; l < n; ++l) {
    long long x;
    while(r < n && rmq.query(0, k) == 0) {
      x = rmq.query(a[r] - 1, a[r]);
      rmq.update(a[r++] - 1, 1 + x);
    }
    if(rmq.query(0, k) != 0) ans = min(ans, r - l);
    x = rmq.query(a[l] - 1, a[l]);
    rmq.update(a[l] - 1, x - 1);
  }
  return ans == inf ? 0 : ans;
}