#include <bits/stdc++.h>
using namespace std;
set<pair<long long, long long> > v;
long long ar[2000000];
int main() {
  long long n, k;
  cin >> n >> k;
  for (long long i = 0; i < n; ++i) {
    long long a;
    cin >> a;
    v.insert(make_pair(a, -i));
  }
  long long e = n;
  long long first = 0, f1 = 0, ma_f = 0, suf_len = 0;
  bool q = false;
  for (long long i = 0; i < n; ++i) {
    pair<long long, long long> a = *v.begin();
    if (-a.second > e) {
      v.erase(v.begin());
      pair<long long, long long> b = *v.begin();
      f1 = k;
      if (b.first != a.first) first = f1;
      continue;
    }
    if (e + a.second > k) {
      if ((!q) && (e + a.second - first <= k)) {
        q = true;
        e = e - first;
      } else {
        cout << "NO";
        exit(0);
      }
    }
    v.erase(v.begin());
    pair<long long, long long> b = *v.begin();
    if (a.first != b.first) {
      first = max(k - (e + a.second), f1);
      e = -a.second;
    }
  }
  cout << "YES";
}
