//#include <fsociety>
#include <cmath>
#include <deque>
#include <algorithm>
#include <iterator>
#include <list>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <unordered_set>
#include <stack>
#include <string>
#include <vector>
#include <fstream>
#include <iostream>
#include <iomanip> 
#include <stdio.h>
//end of libraries ;
// freopen("input.in","r",stdin);
// freopen("output.out","w",stdout);
#define LNF 3999999999999999999
#define INF 999999999
#define PI 3.14159265359
#define endl "\n"
#define fi first
#define se second
#define pb push_back
#define ll long long
#define all(c) (c).begin(),(c).end()
#define sz(c) (int)(c).size()
#define mkp(a,b) make_pair(a,b)
#define rsz(a,n) a.resize(n)
#define pii pair <int,int>
#define fcin ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
 
const int N = rand()%1141;
 
using namespace std;
 
int n;
 
struct segtree{
 
  vector <int> t;
  
  int siz = 1;
 
  void init(){
    while(siz < 2*n){
      siz *= 2;
    }
    t.resize(siz,0);
    // rsz(t , siz);
  }
  
  void upd(int v , int  tl , int tr , int pos , int val){
    if(tl == tr){
      t[v] = t[v]^val;
    } 
    else{
      int tm = (tl + tr) / 2;
      if(pos <= tm)
        upd(v*2 , tl , tm , pos , val);
      else 
        upd(v*2 + 1 , tm + 1 , tr , pos , val);
      t[v] = t[v*2]^t[v*2 + 1];
    }
  }
  
  void upd(int pos , int val){
    upd(1 , 0 , n - 1 , pos , val);
  }
  
  int get(int v , int tl , int tr , int pos){
  	if(tl == tr){
  		return t[v];
  	}
  	int tm = (tl + tr) / 2;
  	if(pos <= tm)
  		return get(v*2 , tl , tm , pos);
  	else
  		return get(v*2 + 1 , tm + 1 , tr , pos);
  }
 
  int get(int pos){
  	return get(1 , 0 , n - 1 , pos);
  }
  
  int get_xor(int v , int tl , int tr , int l , int r){
  	if(tl > r || tr < l) return 0;
  	
  	if(tl == tr){
  		return t[v];
  	}
  	
  	if(tl >= l && tr <= r) return t[v];
  	
  	int tm = (tl + tr)/2;
  	
  	return get_xor(v*2 , tl , tm , l , r)^get_xor(v*2 + 1 , tm + 1 , tr , l , r);
  }
 
  int get_xor(int l , int r){
  	return get_xor(1 , 0 , n - 1 , l , r );
  }
};
 
int main(){
fcin;
	
	int q;
 
	cin >> n >> q;
 
	segtree sg;
	sg.init();
	
	for(int i = 0 ; i < n ; i++){
		int x ; 
		cin >> x;
		sg.upd(i,x);
	}

	while(q--){
		int t , l , r;
		cin >> t >> l >> r;
		l--;
		if(t == 1){
			sg.upd(l,r);
		}
		else{
			r--;
			cout << sg.get_xor(l,r) << "\n";
		}
		
	}
 
	return 0;
}
#include <bits/stdc++.h>

using namespace std;

#define eps 1e-9
#define INF 2000000000              // 2e9
#define LLINF 2000000000000000000ll // 2e18 (llmax:9e18)
#define all(x) (x).begin(), (x).end()
#define sq(x) ((x) * (x))

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define drep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)

#define popcount __builtin_popcount
#define next __next
#define prev __prev

#ifndef LOCAL
#define dmp(...) ;
#else
#define dmp(...)                                                               \
  cerr << "[ " << #__VA_ARGS__ << " ] : " << dump_str(__VA_ARGS__) << endl
#endif

// ---------------- Utility ------------------

template <class T>
bool chmin(T &a, const T &b) {
  if (a <= b) return false;
  a = b;
  return true;
}
template <class T>
bool chmax(T &a, const T &b) {
  if (a >= b) return false;
  a = b;
  return true;
}

template <class T>
using MaxHeap = priority_queue<T>;
template <class T>
using MinHeap = priority_queue<T, vector<T>, greater<T>>;

template <class T>
vector<T> vect(int len, T elem) {
  return vector<T>(len, elem);
}

// ----------------- Input -------------------

template <class T, class U>
istream &operator>>(istream &is, pair<T, U> &p) {
  return is >> p.first >> p.second;
}

template <class T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) is >> vec[i];
  return is;
}

// ----------------- Output ------------------

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  return os << p.first << ',' << p.second;
}

template <class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  for (const T &e : v) os << e << " ";
  return os;
}

template <class T>
ostream &operator<<(ostream &os, const deque<T> &d) {
  for (const T &e : d) os << e << " ";
  return os;
}

template <class T>
ostream &operator<<(ostream &os, const set<T> &s) {
  os << "{ ";
  for (const T &e : s) os << e << " ";
  return os << "}";
}

template <class T, class U>
ostream &operator<<(ostream &os, const map<T, U> &m) {
  os << "{ ";
  for (const auto &[key, val] : m) os << "( " << key << " -> " << val << " ) ";
  return os << "}";
}

template <class TupleTy, size_t... I>
void dump_tuple(ostream &os, const TupleTy t, std::index_sequence<I...>) {
  (..., (os << (I == 0 ? "" : ",") << std::get<I>(t)));
}

template <class... Args>
ostream &operator<<(ostream &os, const tuple<Args...> &t) {
  os << "(";
  dump_tuple(os, t, std::make_index_sequence<sizeof...(Args)>());
  return os << ")";
}

void dump_str_rec(ostringstream &) {}

template <class Head, class... Tail>
void dump_str_rec(ostringstream &oss, Head &&head, Tail &&... tail) {
  oss << ", " << head;
  dump_str_rec(oss, forward<Tail>(tail)...);
}

template <class T, class... U>
string dump_str(T &&arg, U &&... args) {
  ostringstream oss;
  oss << arg;
  dump_str_rec(oss, forward<U>(args)...);
  return oss.str();
}

// --------------- Fast I/O ------------------

void fastio() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(20);
}

// ------------ End of template --------------

#define endl "\n"
using ll = long long;
using pii = pair<int, int>;

void solve() {
  int N, M;
  cin >> N >> M;
  vector<int> A(N);
  cin >> A;
  vector<vector<int>> pos(N + 1);
  rep(i, N) pos[A[i]].push_back(i);
  for (int i = 0; i <= N; i++) {
    if (pos[i].empty()) {
      cout << i << endl;
      return;
    }
    pos[i].push_back(N);
    int cur = -1;
    for (int j = 0; j < pos[i].size(); j++) {
      if (pos[i][j] - cur >= M + 1) {
        cout << i << endl;
        return;
      }
      cur = pos[i][j];
    }
  }
  return;
}

int main() {
  fastio();
  solve();
  // int t; cin >> t; while(t--)solve();

  // int t; cin >> t;
  // for(int i=1;i<=t;i++){
  //   cout << "Case #" << i << ": ";
  //   solve();
  // }
  return 0;
}
