#include<bits/stdc++.h>
#define forn(i, n) for (int i = 0; i < n; i++)
#define form(i, n) for (int i = n-1; i >=0; i--)
#define forx(i,x,n) for (int i = x; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define sz(a) int(a.size())
#define pb push_back
#define ll long long
#define srt(a) sort(a.begin(), a.end());
#define pl pair<long long,long long>
#define pi pair<int, int>
#define fi first
#define se second
#define ve vector
using namespace std;
const int inf = 1e9;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr);
    int n, m, k, l; cin >> n >> m;
    ve<int> c(n); forn(i, n) cin >> c[i];
    multiset<int> a; set<int> b;
    forn(i, m+1) { b.insert(i); }
    forn(i, m) {
        a.insert(c[i]); b.erase(c[i]);
    }
    int R = *b.begin();
    forx(i, m, n) {
        a.insert(c[i]); 
        a.erase(a.find(c[i - m]));
        if (a.count(c[i-m])==0) b.insert(c[i - m]);
        b.erase(c[i]);
        R = min(R, *b.begin());
    }
    cout << R;


}
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0,endrep=(n); i<endrep; ++i)
#define rep1(i,n) for(ll i=1,endrep=(n); i<=endrep; ++i)
#define revrep(i,n) for(ll i=(ll)(n)-1; i>=0; --i)
inline constexpr ll Inf = (1ULL << 60) -123456789;
#define fastio cin.tie(0); ios_base::sync_with_stdio(false); cout<<fixed<<setprecision(10);
#define newl '\n'
#define YN(e) ((e)?"Yes":"No")
#define all(a) begin(a),end(a)
#define rall(a) rbegin(a),rend(a)
#define delif(c,pred) (c).erase(remove_if(all(c),(pred)), end(c))
template <class T,class U> bool updmax(T& a, U b) { if(b>a){ a=b; return true;} return false;}
template <class T,class U> bool updmin(T& a, U b) { if(b<a){ a=b; return true;} return false;}
inline constexpr int Mod = 1000000007;
//inline constexpr int Mod = 998244353;
#define dbg(a) cerr << #a << ": " << a << endl;
#define dbgs(s) cerr << #s << endl;
#define dbg1(a,n) cerr<<#a<<": "; rep(i,n) cerr<<a[i]<<" "; cerr<<endl;
#define dbg2(m,h,w) cerr<<#m<<":"<<endl; rep(i,h){ rep(j,w)cerr<<m[i][j]<<" "; cerr<<endl; }
template <class T, class U> ostream& operator << (ostream& os, pair<T,U> v) {os<<v.first<<","<<v.second;return os;}
template <class T, size_t N> ostream& operator << (ostream& os, array<T,N> v) {rep(i,N)os<<v[i]<<(i+1<(ll)N?" ":"");return os;}
int rng(int n) { return rand()/(RAND_MAX+1.0)*n; }

int main() {
    fastio;
    ll ans{};
    ll a,b,c;
    cin >> a >> b >> c;
  ans = 21-a-b-c;
    cout << ans << endl;
}
