#include <bits/stdc++.h>
using namespace std;

vector <int> cn[510];

int a[510],b [510],c[510],vis[510];

string anw = "";

void pa (int u)
{
	for (int i = 0; i < cn[u].size(); i++)
	{
		if (b[cn[u][i]]) continue;
		anw += 'a';
		a[cn[u][i]]++;
	}
}

void pc (int u)
{
	for (int i = 0; i < cn[u].size(); i++)
	{
		if (b[cn[u][i]]) continue;
		anw += 'c';
		c[cn[u][i]]++;
	}
}

int main()
{
	int n,m,u,v;
	scanf("%d%d",&n,&m);
	for (int i = 0; i < m; i++)
	{
		scanf("%d%d",&u,&v);
		u--;v--;
		cn[u].push_back(v);
		cn[v].push_back(u);
	}

	for (int i = 0; i < n; i++)
	{
		if (cn[i].size() != n-1) continue;
		anw += 'b';
		b[i] = 1;
	}

	int i = 0;
	for (; i < n; i++)
	{
		if (b[i]) continue;
		pa(i);
		for (int j = 0; j < cn[i].size(); j++)
		{
			if (b[cn[i][j]]) continue;
			pa(cn[i][j]);
		}
		for (int j = 0; j < n; j++)
		{
			if (a[j] != 0 && a[j] != cn[i].size())
			{
				printf("No\n");
				return 0;
			}
		}
		i++;
	}

	for (; i < n; i++)
	{
		if (b[i]) continue;
		pc(i);
		for (int j = 0; j < cn[i].size(); j++)
		{
			if (b[cn[i][j]]) continue;
			pc(cn[i][j]);
		}
		for (int j = 0; j < n; j++)
		{
			if (c[j] != 0 && c[j] != cn[i].size())
			{
				printf("No\n");
				return 0;
			}
		}
	}

	if (anw.size() != n) cout << "No" << endl;
	else cout << "Yes" << endl << anw << endl;
}


#include <bits/stdc++.h>
using namespace std;

vector <int> cn[510];

int a[510],b [510],c[510];

string anw = "";

void pa (int u)
{
	anw += 'a';
	for (int i = 0; i < cn[u].size(); i++)
	{
		if (b[cn[u][i]]) continue;
		a[cn[u][i]]++;
	}
}

void pc (int u)
{
	anw += 'c';
	for (int i = 0; i < cn[u].size(); i++)
	{
		if (b[cn[u][i]]) continue;
		c[cn[u][i]]++;
	}
}

int main()
{
	int n,m,u,v;
	scanf("%d%d",&n,&m);
	for (int i = 0; i < m; i++)
	{
		scanf("%d%d",&u,&v);
		u--;v--;
		cn[u].push_back(v);
		cn[v].push_back(u);
	}

	for (int i = 0; i < n; i++)
	{
		if (cn[i].size() != n-1) continue;
		anw += 'b';
		b[i] = 1;
	}

	int i = 0;
	for (; i < n; i++)
	{
		if (b[i]) continue;
		pa(i);
		int sz = 0;
		for (int j = 0; j < cn[i].size(); j++)
		{
			if (b[cn[i][j]]) continue;
			sz++;
			pa(cn[i][j]);
		}
		for (int j = 0; j < n; j++)
		{
			if (a[j] != 0 && a[j] != sz)
			{
				printf("No\n");
				return 0;
			}
		}
		i++;
		break;
	}

	for (; i < n; i++)
	{
		if (b[i]) continue;
		pc(i);
		int sz =0;
		for (int j = 0; j < cn[i].size(); j++)
		{
			if (b[cn[i][j]]) continue;
			sz++;
			pc(cn[i][j]);
		}
		for (int j = 0; j < n; j++)
		{
			if (c[j] != 0 && c[j] != sz)
			{
				printf("No\n");
				return 0;
			}
		}
		break;
	}
	if (anw.size() != n) cout << "No" << endl;
	else cout << "Yes" << endl << anw << endl;
}


#include <bits/stdc++.h>
using namespace std;

vector <int> cn[510];

int a[510],b [510],c[510];

string anw = "";

void pa (int u)
{
	anw[u] = 'a';
	for (int i = 0; i < cn[u].size(); i++)
	{
		if (b[cn[u][i]]) continue;
		a[cn[u][i]]++;
	}
}

void pc (int u)
{
	anw[u] = 'c';
	for (int i = 0; i < cn[u].size(); i++)
	{
		if (b[cn[u][i]]) continue;
		c[cn[u][i]]++;
	}
}

int main()
{
	int n,m,u,v;
	scanf("%d%d",&n,&m);
	for (int i = 0; i < m; i++)
	{
		scanf("%d%d",&u,&v);
		anw += " ";
		u--;v--;
		cn[u].push_back(v);
		cn[v].push_back(u);
	}

	int sa = 0;
	for (int i = 0; i < n; i++)
	{
		if (cn[i].size() != n-1) continue;
		anw[i] = 'b';
		b[i] = 1;
		sa++;
	}
	int i = 0;
	for (; i < n; i++)
	{
		if (b[i]) continue;
		pa(i);
		int sz = 0;
		for (int j = 0; j < cn[i].size(); j++)
		{
			if (b[cn[i][j]]) continue;
			sz++;
			pa(cn[i][j]);
		}
		if (a[i] != sz)
		{
			printf("No\n");
			return 0;
		}
		a[i] = 1e3;
		for (int j = 0; j < cn[i].size(); j++)
		{
			if (b[cn[i][j]]) continue;
			if (a[cn[i][j]] != sz)
			{
				printf("No\n");
				return 0;
			}
			a[cn[i][j]] = 1e3;
		}
		for (int j = 0; j < n; j++)
		{
			if (a[j] == 1e3 || a[j] == 0) continue;
			printf("No\n");
			return 0;
		}
		i++;
		sa += sz+1;
		break;
	}
	for (; i < n; i++)
	{
		if (b[i] || a[i]) continue;
		pc(i);
		int sz = 0;
		for (int j = 0; j < cn[i].size(); j++)
		{
			if (b[cn[i][j]]) continue;
			sz++;
			pc(cn[i][j]);
		}
		if (c[i] != sz)
		{
			printf("No\n");
			return 0;
		}
		c[i] = 1e3;
		for (int j = 0; j < cn[i].size(); j++)
		{
			if (b[cn[i][j]]) continue;
			if (c[cn[i][j]] != sz)
			{
				printf("No\n");
				return 0;
			}
			c[cn[i][j]] = 1e3;
		}
		for (int j = 0; j < n; j++)
		{
			if (c[j] == 1e3 || c[j] == 0) continue;
			printf("No\n");
			return 0;
		}
		sa += sz+1;
		break;
	}
	if (sa != n) cout << "No" << endl;
	else cout << "Yes" << endl << anw << endl;
}


#include <bits/stdc++.h>
using namespace std;

vector <int> cn[510];

int a[510],b [510],c[510];

string anw = "";

void pa (int u)
{
	anw[u] = 'a';
	for (int i = 0; i < cn[u].size(); i++)
	{
		if (b[cn[u][i]]) continue;
		a[cn[u][i]]++;
	}
}

void pc (int u)
{
	anw[u] = 'c';
	for (int i = 0; i < cn[u].size(); i++)
	{
		if (b[cn[u][i]]) continue;
		c[cn[u][i]]++;
	}
}

int main()
{
	int n,m,u,v;
	scanf("%d%d",&n,&m);
	for (int i = 0; i < m; i++)
	{
		scanf("%d%d",&u,&v);
		anw += " ";
		u--;v--;
		cn[u].push_back(v);
		cn[v].push_back(u);
	}

	int sa = 0;
	for (int i = 0; i < n; i++)
	{
		if (cn[i].size() != n-1) continue;
		anw[i] = 'b';
		b[i] = 1;
		sa++;
	}

	int i = 0;
	for (; i < n; i++)
	{
		if (b[i]) continue;
		pa(i);
		int sz = 0;
		for (int j = 0; j < cn[i].size(); j++)
		{
			if (b[cn[i][j]]) continue;
			sz++;
			pa(cn[i][j]);
		}
		for (int j = 0; j < n; j++)
		{
			if (a[j] != 0 && a[j] != sz)
			{
				printf("No\n");
				return 0;
			}
		}
		i++;
		sa += sz+1;
		break;
	}

	for (; i < n; i++)
	{
		if (b[i] || a[i]) continue;
		pc(i);
		int sz = 0;
		for (int j = 0; j < cn[i].size(); j++)
		{
			if (b[cn[i][j]]) continue;
			sz++;
			pc(cn[i][j]);
		}
		for (int j = 0; j < n; j++)
		{
			if (c[j] != 0 && c[j] != sz)
			{
				printf("No\n");
				return 0;
			}
		}
		sa += sz+1;
		break;
	}

	if (sa != n) cout << "No" << endl;
	else cout << "Yes" << endl << anw << endl;
}


#include <bits/stdc++.h>
using namespace std;

vector <int> cn[510];

int a[510],b [510],c[510];

string anw = "";

void pa (int u)
{
	anw[u] = 'a';
	for (int i = 0; i < cn[u].size(); i++)
	{
		if (b[cn[u][i]]) continue;
		a[cn[u][i]]++;
	}
}

void pc (int u)
{
	anw[u] = 'c';
	for (int i = 0; i < cn[u].size(); i++)
	{
		if (b[cn[u][i]]) continue;
		c[cn[u][i]]++;
	}
}

int main()
{
	int n,m,u,v;
	scanf("%d%d",&n,&m);
	for (int i = 0; i < m; i++)
	{
		scanf("%d%d",&u,&v);
		u--;v--;
		cn[u].push_back(v);
		cn[v].push_back(u);
	}

	int sa = 0;
	for (int i = 0; i < n; i++)
	{
	    anw += " ";
		if (cn[i].size() != n-1) continue;
		anw[i] = 'b';
		b[i] = 1;
		sa++;
	}
	int i = 0;
	for (; i < n; i++)
	{
		if (b[i]) continue;
		pa(i);
		int sz = 0;
		for (int j = 0; j < cn[i].size(); j++)
		{
			if (b[cn[i][j]]) continue;
			sz++;
			pa(cn[i][j]);
		}
		if (a[i] != sz)
		{
			printf("No\n");
			return 0;
		}
		a[i] = 1e3;
		for (int j = 0; j < cn[i].size(); j++)
		{
			if (b[cn[i][j]]) continue;
			if (a[cn[i][j]] != sz)
			{
				printf("No\n");
				return 0;
			}
			a[cn[i][j]] = 1e3;
		}
		for (int j = 0; j < n; j++)
		{
			if (a[j] == 1e3 || a[j] == 0) continue;
			printf("No\n");
			return 0;
		}
		i++;
		sa += sz+1;
		break;
	}
	for (; i < n; i++)
	{
		if (b[i] || a[i]) continue;
		pc(i);
		int sz = 0;
		for (int j = 0; j < cn[i].size(); j++)
		{
			if (b[cn[i][j]]) continue;
			sz++;
			pc(cn[i][j]);
		}
		if (c[i] != sz)
		{
			printf("No\n");
			return 0;
		}
		c[i] = 1e3;
		for (int j = 0; j < cn[i].size(); j++)
		{
			if (b[cn[i][j]]) continue;
			if (c[cn[i][j]] != sz)
			{
				printf("No\n");
				return 0;
			}
			c[cn[i][j]] = 1e3;
		}
		for (int j = 0; j < n; j++)
		{
			if (c[j] == 1e3 || c[j] == 0) continue;
			printf("No\n");
			return 0;
		}
		sa += sz+1;
		break;
	}
	if (sa != n) cout << "No" << endl;
	else cout << "Yes" << endl << anw << endl;
}


#include <bits/stdc++.h>
using namespace std;

vector <int> cn[510];

int a[510],b [510],c[510];

string anw = "";

void pa (int u)
{
	anw[u] = 'a';
	for (int i = 0; i < cn[u].size(); i++)
	{
		if (b[cn[u][i]]) continue;
		a[cn[u][i]]++;
	}
}

void pc (int u)
{
	anw[u] = 'c';
	for (int i = 0; i < cn[u].size(); i++)
	{
		if (b[cn[u][i]]) continue;
		c[cn[u][i]]++;
	}
}

int main()
{
	int n,m,u,v;
	scanf("%d%d",&n,&m);
	for (int i = 0; i < m; i++)
	{
		scanf("%d%d",&u,&v);
		u--;v--;
		cn[u].push_back(v);
		cn[v].push_back(u);
	}

	int sa = 0;
	for (int i = 0; i < n; i++)
	{
	    anw += " ";
		if (cn[i].size() != n-1) continue;
		anw[i] = 'b';
		b[i] = 1;
		sa++;
	}

	int i = 0;
	for (; i < n; i++)
	{
		if (b[i]) continue;
		pa(i);
		int sz = 0;
		for (int j = 0; j < cn[i].size(); j++)
		{
			if (b[cn[i][j]]) continue;
			sz++;
			pa(cn[i][j]);
		}
		for (int j = 0; j < n; j++)
		{
			if (a[j] != 0 && a[j] != sz)
			{
				printf("No\n");
				return 0;
			}
		}
		i++;
		sa += sz+1;
		break;
	}

	for (; i < n; i++)
	{
		if (b[i] || a[i]) continue;
		pc(i);
		int sz = 0;
		for (int j = 0; j < cn[i].size(); j++)
		{
			if (b[cn[i][j]]) continue;
			sz++;
			pc(cn[i][j]);
		}
		for (int j = 0; j < n; j++)
		{
			if (c[j] != 0 && c[j] != sz)
			{
				printf("No\n");
				return 0;
			}
		}
		sa += sz+1;
		break;
	}

	if (sa != n) cout << "No" << endl;
	else cout << "Yes" << endl << anw << endl;
}


//#include <bits/stdc++.h>
#include <cstdio>
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map>
#include <set>

using namespace std;

#define F first
#define S second
#define pb push_back
#define mp make_pair

bool gr[501][501];

vector<vector<int> > g;

int p[510];

bool bfs(int v) {
    if (g[v].size() == 0) {
        p[v] = 2;
        return true;
    }
    p[v] = 1;
    queue<int> q;
    q.push(v);
    while (!q.empty()) {
        int v = q.front();
        q.pop();
        for (int i = 0; i < g[v].size(); i++) {
            int to = g[v][i];
            if (p[to] == 0) {
                p[to] = 4 - p[v];
                q.push(to);
            } else if (p[to] + p[v] != 4)
                return false;
        }
    }
    return true;
}

int main() {
    ios_base::sync_with_stdio(0);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif // LOCAL
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        int x, y;
        cin >> x >> y;
        x--;
        y--;
        gr[x][y] = true;
        gr[y][x] = true;
    }
    g.resize(n);
    for (int i = 0; i < n; i++)
        for (int j = i + 1; j < n; j++)
            if (!gr[i][j]) {
                g[i].push_back(j);
                g[j].push_back(i);
            }
    for (int i = 0; i < n; i++)
        if (p[i] == 0) {
            bool f = bfs(i);
            if (!f) {
                cout << "No" << endl;
                return 0;
            }
        }
    cout << "Yes" << endl;
    for (int i = 0; i < n; i++)
        cout << (char)(p[i] - 1 + 'a');
    return 0;
}


//#include <bits/stdc++.h>
#include <cstdio>
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map>
#include <set>

using namespace std;

#define F first
#define S second
#define pb push_back
#define mp make_pair

bool gr[501][501];

vector<vector<int> > g;

int p[501];

bool bfs(int v) {
    if (g[v].size() == 0) {
        p[v] = 2;
        return true;
    }
    p[v] = 1;
    queue<int> q;
    q.push(v);
    while (!q.empty()) {
        int v = q.front();
        q.pop();
        for (int i = 0; i < g[v].size(); i++) {
            int to = g[v][i];
            if (p[to] == 0) {
                p[to] = 4 - p[v];
                q.push(to);
            } else if (p[to] + p[v] != 4)
                return false;
        }
    }
    return true;
}

int main() {
    //ios_base::sync_with_stdio(0);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif // LOCAL
    int n, m;
    //cin >> n >> m;
    scanf("%d%d", &n, &m);
    for (int i = 0; i < m; i++) {
        int x, y;
        //cin >> x >> y;
        scanf("%d%d", &x, &y);
        x--;
        y--;
        gr[x][y] = true;
        gr[y][x] = true;
    }
    g.resize(n);
    for (int i = 0; i < n; i++)
        for (int j = i + 1; j < n; j++)
            if (!gr[i][j]) {
                g[i].push_back(j);
                g[j].push_back(i);
            }
    for (int i = 0; i < n; i++)
        if (p[i] == 0) {
            bool f = bfs(i);
            if (!f) {
                puts("No");
                return 0;
            }
        }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (i == j)
                continue;
            if (gr[i][j]) {
                if (abs(p[i] - p[j]) > 1) {
                    puts("No");
                    return 0;
                }
            }
            if (!gr[i][j]) {
                if (abs(p[i] - p[j]) < 2) {
                    puts("No");
                    return 0;
                }
            }
        }
    }
    puts("Yes");
    for (int i = 0; i < n; i++)
        putchar((char)(p[i] - 1 + 'a'));
    return 0;
}


//#include <bits/stdc++.h>
#include <cstdio>
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map>
#include <set>

using namespace std;

#define F first
#define S second
#define pb push_back
#define mp make_pair

bool gr[501][501];

vector<vector<int> > g;

int p[510];

bool bfs(int v) {
    if (g[v].size() == 0) {
        p[v] = 3;
        return true;
    }
    p[v] = 1;
    queue<int> q;
    q.push(v);
    while (!q.empty()) {
        int v = q.front();
        q.pop();
        for (int i = 0; i < g[v].size(); i++) {
            int to = g[v][i];
            if (p[to] == 0) {
                p[to] = 3 - p[v];
                q.push(to);
            } else if (p[to] + p[v] != 3)
                return false;
        }
    }
    return true;
}

int main() {
    ios_base::sync_with_stdio(0);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif // LOCAL
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        int x, y;
        cin >> x >> y;
        x--;
        y--;
        gr[x][y] = true;
        gr[y][x] = true;
    }
    g.resize(n);
    for (int i = 0; i < n; i++)
        for (int j = i + 1; j < n; j++)
            if (!gr[i][j]) {
                g[i].push_back(j);
                g[j].push_back(i);
            }
    for (int i = 0; i < n; i++)
        if (p[i] == 0) {
            bool f = bfs(i);
            if (!f) {
                cout << "No" << endl;
                return 0;
            }
        }
    cout << "Yes" << endl;
    for (int i = 0; i < n; i++)
        cout << (char)(p[i] - 1 + 'a');
    return 0;
}


//#include <bits/stdc++.h>
#include <cstdio>
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map>
#include <set>

using namespace std;

#define F first
#define S second
#define pb push_back
#define mp make_pair

bool gr[501][501];

vector<vector<int> > g;

int p[510];

bool bfs(int v) {
    if (g[v].size() == 0) {
        p[v] = 2;
        return true;
    }
    p[v] = 1;
    queue<int> q;
    q.push(v);
    while (!q.empty()) {
        int v = q.front();
        q.pop();
        for (int i = 0; i < g[v].size(); i++) {
            int to = g[v][i];
            if (p[to] == 0) {
                p[to] = 4 - p[v];
                q.push(to);
            } else if (p[to] + p[v] != 4)
                return false;
        }
    }
    return true;
}

int main() {
    ios_base::sync_with_stdio(0);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif // LOCAL
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        int x, y;
        cin >> x >> y;
        x--;
        y--;
        gr[x][y] = true;
        gr[y][x] = true;
    }
    g.resize(n);
    for (int i = 0; i < n; i++)
        for (int j = i + 1; j < n; j++)
            if (!gr[i][j]) {
                g[i].push_back(j);
                g[j].push_back(i);
            }
    for (int i = 0; i < n; i++)
        if (p[i] == 0) {
            bool f = bfs(i);
            if (!f) {
                cout << "No" << endl;
                return 0;
            }
        }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (i == j)
                continue;
            if (gr[i][j]) {
                if (abs(p[i] - p[j]) > 1) {
                    cout << "No" << endl;
                    return 0;
                }
            }
            if (!gr[i][j]) {
                if (abs(p[i] - p[j]) < 2) {
                    cout << "No" << endl;
                    return 0;
                }
            }
        }
    }
    cout << "Yes" << endl;
    for (int i = 0; i < n; i++)
        cout << (char)(p[i] - 1 + 'a');
    return 0;
}


//#include <bits/stdc++.h>
#include <cstdio>
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map>
#include <set>

using namespace std;

#define F first
#define S second
#define pb push_back
#define mp make_pair

bool gr[501][501];

vector<vector<int> > g;

int p[510];

bool bfs(int v){
    if (g[v].size() == 1){
        p[v] = 3;
        return true;
    }
    p[v] = 1;
    queue<int> q;
    q.push(v);
    while (!q.empty()){
        int v = q.front();
        q.pop();
        for (int i=0;i<g[v].size();i++){
            int to = g[v][i];
            if (p[to] == 0){
                p[to] = 3 - p[v];
                q.push(to);
            }
            else
                if (p[to] + p[v] != 3)
                    return false;
        }
    }
    return true;
}

int main() {
    ios_base::sync_with_stdio(0);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif // LOCAL
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        int x, y;
        cin >> x >> y;
        x--;
        y--;
        gr[x][y] = true;
        gr[y][x] = true;
    }
    g.resize(n);
    for (int i=0;i<n;i++)
        for (int j=i + 1;j<n;j++)
            if (!gr[i][j]){
                g[i].push_back(j);
                g[j].push_back(i);
            }
    for (int i=0;i<n;i++)
        if (p[i] == 0){
            bool f = bfs(i);
            if (!f){
                cout << "No" << endl;
                return 0;
            }
        }
    cout << "Yes" << endl;
    for (int i=0;i<n;i++)
        cout << (char)(p[i] - 1 + 'a');
    return 0;
}


//#include <bits/stdc++.h>
#include <cstdio>
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map>
#include <set>

using namespace std;

#define F first
#define S second
#define pb push_back
#define mp make_pair

bool gr[501][501];

vector<vector<int> > g;

int p[510];

bool bfs(int v){
    if (g[v].size() == 1){
        p[v] = 3;
        return true;
    }
    p[v] = 1;
    queue<int> q;
    q.push(v);
    while (!q.empty()){
        int v = q.front();
        q.pop();
        for (int i=0;i<g[v].size();i++){
            int to = g[v][i];
            if (p[to] == 0){
                p[to] = 3 - p[v];
                q.push(to);
            }
            else
                if (p[to] + p[v] != 3)
                    return false;
        }
    }
    return true;
}

int main() {
    ios_base::sync_with_stdio(0);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif // LOCAL
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        int x, y;
        cin >> x >> y;
        x--;
        y--;
        gr[x][y] = true;
        gr[y][x] = true;
    }
    g.resize(n);
    for (int i=0;i<n;i++)
        for (int j=i + 1;j<n;j++)
            if (!gr[i][j]){
                g[i].push_back(j);
                g[j].push_back(i);
            }
    for (int i=0;i<n;i++)
        if (p[i] == 0){
            bool f = bfs(i);
            if (!f){
                cout << "No" << endl;
                return 0;
            }
        }
    cout << "Yes" << endl;
    for (int i=0;i<n;i++)
        cout << (char)(p[i] - 1 + 'a');
    return 0;
}


//#include <bits/stdc++.h>
#include <cstdio>
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map>
#include <set>

using namespace std;

#define F first
#define S second
#define pb push_back
#define mp make_pair

bool gr[501][501];

vector<vector<int> > g;

int p[501];

bool bfs(int v) {
    if (g[v].size() == 0) {
        p[v] = 2;
        return true;
    }
    p[v] = 1;
    queue<int> q;
    q.push(v);
    while (!q.empty()) {
        int v = q.front();
        q.pop();
        for (int i = 0; i < g[v].size(); i++) {
            int to = g[v][i];
            if (p[to] == 0) {
                p[to] = 4 - p[v];
                q.push(to);
            } else if (p[to] + p[v] != 4)
                return false;
        }
    }
    return true;
}

int main() {
    //ios_base::sync_with_stdio(0);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif // LOCAL
    int n, m;
    //cin >> n >> m;
    scanf("%d%d", &n, &m);
    for (int i = 0; i < m; i++) {
        int x, y;
        cin >> x >> y;
        x--;
        y--;
        gr[x][y] = true;
        gr[y][x] = true;
    }
    g.resize(n);
    for (int i = 0; i < n; i++)
        for (int j = i + 1; j < n; j++)
            if (!gr[i][j]) {
                g[i].push_back(j);
                g[j].push_back(i);
            }
    for (int i = 0; i < n; i++)
        if (p[i] == 0) {
            bool f = bfs(i);
            if (!f) {
                puts("No");
                return 0;
            }
        }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (i == j)
                continue;
            if (gr[i][j]) {
                if (abs(p[i] - p[j]) > 1) {
                    puts("No");
                    return 0;
                }
            }
            if (!gr[i][j]) {
                if (abs(p[i] - p[j]) < 2) {
                    puts("No");
                    return 0;
                }
            }
        }
    }
    puts("Yes");
    for (int i = 0; i < n; i++)
        putchar((char)(p[i] - 1 + 'a'));
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int mod = 1e9 + 7;
const int nmax = 100005;
const ll inf = 1e9;
const double eps = 1e-6;
int a[505][505];
string ans;
int used[505];
int deg[505];
int n, m;
void dfs(int v, char c){
    used[v] = 1;
    ans[v] = c;
    for(int i = 0; i < n; ++i){
        if (!used[i] && !a[v][i]){
            if (c == 'a') dfs(i, 'c');
            else dfs(i, 'a');
        }
    }
}
int main(){
    ios_base::sync_with_stdio(0);
    cin >> n;
    cin >> m;
    for(int i = 0; i < n; ++i) ans += 'b';
    for(int i = 0; i < m; ++i){
        int u, v;
        cin >> u >> v;
        u--; v--;
        a[u][v] = a[v][u] = 1;
        deg[u]++;
        deg[v]++;
    }
    for(int i = 0; i < n; ++i){
        if (deg[i] < n - 1 && !used[i]){
            dfs(i, 'a');
        }
    }
    for(int i = 0; i < n; ++i){
        for(int j = i + 1; j < n; ++j){
            if (a[i][j]){
                if (ans[i] == 'a' && ans[j] == 'c'){
                    cout << "No\n";
                    return 0;
                }
                else if (ans[i] == 'c' && ans[j] == 'a'){
                    cout << "No\n";
                    return 0;
                }
            }
            else {
                if (ans[i] == ans[j]){
                    cout << "No\n";
                    return 0;
                }
                else if (ans[i] == 'b' || ans[j] == 'b'){
                    cout << "No\n";
                    return 0;
                }
            }
        }
    }
    cout << "Yes\n";
    cout << ans << '\n';
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int mod = 1e9 + 7;
const int nmax = 100005;
const ll inf = 1e9;
const double eps = 1e-6;
int a[505][505];
string ans;
int main(){
    ios_base::sync_with_stdio(0);
    int n;
    cin >> n;
    int m;
    cin >> m;
    for(int i = 0; i < n; ++i) ans += 'b';
    for(int i = 0; i < m; ++i){
        int u, v;
        cin >> u >> v;
        u--; v--;
        a[u][v] = a[v][u] = 1;
    }
    if (m < n - 1){
        cout << "No\n";
        return 0;
    }
    for(int i = 0; i < n; ++i){
        for(int k = i + 1; k < n; ++k){
            for(int j = 0; j < n; ++j){
                if (a[i][j] && a[k][j]){
                    if (!a[i][k]){
                        if (ans[i] != 'b' && ans[k] != 'b'){
                            if (ans[i] == ans[k]){
                                cout << "No\n";
                                return 0;
                            }
                        }
                        else {
                            if (ans[i] != 'b'){
                                if (ans[i] == 'a') ans[k] = 'c';
                                else ans[k] = 'a';
                            }
                            else if (ans[k] != 'b'){
                                if (ans[k] == 'a') ans[i] = 'c';
                                else ans[i] = 'a';
                            }
                            else {
                                ans[i] = 'a';
                                ans[k] = 'c';
                            }
                        }
                    }
                }
            }
        }
    }
    for(int i = 0; i < n; ++i){
        for(int k = i + 1; k < n; ++k){
            if (a[i][k]){
                if (ans[i] == 'a' && ans[k] == 'c'){
                    cout << "No\n";
                    return 0;
                }
                else if (ans[i] == 'c' && ans[k] == 'a'){
                    cout << "No\n";
                    return 0;
                }
            }
        }
    }
    cout << "Yes\n";
    cout << ans << '\n';
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int mod = 1e9 + 7;
const int nmax = 100005;
const ll inf = 1e9;
const double eps = 1e-6;
int a[505][505];
string ans;
int main(){
    ios_base::sync_with_stdio(0);
    int n;
    cin >> n;
    int m;
    cin >> m;
    for(int i = 0; i < n; ++i) ans += 'b';
    for(int i = 0; i < m; ++i){
        int u, v;
        cin >> u >> v;
        u--; v--;
        a[u][v] = a[v][u] = 1;
    }
    if (m < n - 1){
        cout << "No\n";
        return 0;
    }
    for(int i = 0; i < n; ++i){
        for(int k = i + 1; k < n; ++k){
            for(int j = 0; j < n; ++j){
                if (a[i][j] && a[k][j]){
                    if (!a[i][k]){
                        if (ans[i] != 'b' && ans[k] != 'b'){
                            if (ans[i] == ans[k]){
                                cout << "No\n";
                                return 0;
                            }
                        }
                        else {
                            if (ans[i] != 'b'){
                                if (ans[i] == 'a') ans[k] = 'c';
                                else ans[k] = 'a';
                            }
                            else if (ans[k] != 'b'){
                                if (ans[k] == 'a') ans[i] = 'c';
                                else ans[i] = 'a';
                            }
                            else {
                                ans[i] = 'a';
                                ans[k] = 'c';
                            }
                        }
                    }
                }
            }
        }
    }
    for(int i = 0; i < n; ++i){
        for(int k = i + 1; k < n; ++k){
            for(int j = 0; j < n; ++j){
                if (a[i][j] && a[k][j]){
                    if (!a[i][k]){
                        if (ans[i] != 'b' && ans[k] != 'b'){
                            if (ans[i] == ans[k]){
                                cout << "No\n";
                                return 0;
                            }
                        }
                    }
                }
            }
        }
    }
    cout << "Yes\n";
    cout << ans << '\n';
    return 0;
}


#pragma GCC target ("sse4.2")
#include<bits/stdc++.h>

using namespace std;

#define F first
#define S second
#define PB push_back
#define ln "\n"
#define forn(i,e) for(ll i=0; i<e; i++)
#define forsn(i,s,e) for(ll i=s; i<e; i++)
#define rforn(i,e) for(ll i=e; i>=0; i--)
#define rforsn(i,e,s) for(ll i=e; i>=s; i--)
#define vasort(v)         sort(v.begin(), v.end());
#define vdsort(v)         sort(v.begin(), v.end(),greater<ll>());
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define     mem(a,b)        memset(a,b,sizeof(a))
#define     sz(x)           ((int)size(x))
#define     EB              emplace_back
#define     flush           fflush(stdout)
#define out1(x1) cout << x1 << ln
#define out2(x1,x2) cout << x1 << " " << x2 << endl
#define out3(x1,x2,x3) cout << x1 << " " << x2 << " " << x3 << ln
#define out4(x1,x2,x3,x4) cout << x1 << " " << x2 << " " << x3 << " " << x4 << ln
#define all(d) d.begin(), d.end()
#define unordered_set(T) unordered_set<T, custom_hash>
#define unordered_map(T1, T2) unordered_map<T1, T2, custom_hash>

#define in1(x1) cin >> x1
#define in2(x1,x2) cin >> x1 >> x2
#define in3(x1,x2,x3) cin >> x1 >> x2 >> x3
#define in4(x1,x2,x3,x4) cin >> x1 >> x2 >> x3 >> x4

#define arrin(a, n) forn(i, n) cin >> a[i];
#define arrout(a,n) forn(i,n) {cout << a[i] << " ";} cout << ln;

/* ---------------- IO ----------------*/

namespace IO
{
    const int BUFFER_SIZE = 1 << 15;
    char input_buffer[BUFFER_SIZE];
    int input_pos = 0, input_len = 0;
    char output_buffer[BUFFER_SIZE];
    int output_pos = 0;
    char number_buffer[100];
    uint8_t lookup[100];
    void _update_input_buffer()
    {
        input_len = fread(input_buffer, sizeof(char), BUFFER_SIZE, stdin);
        input_pos = 0;
        if (input_len == 0)
            input_buffer[0] = EOF;
    }
    inline char next_char(bool advance = true)
    {
        if (input_pos >= input_len)
            _update_input_buffer();

        return input_buffer[advance ? input_pos++ : input_pos];
    }

    template <typename T>
    inline void read_int(T &number)
    {
        bool negative = false;
        number = 0;

        while (!isdigit(next_char(false)))
            if (next_char() == '-')
                negative = true;

        do
        {
            number = 10 * number + (next_char() - '0');
        } while (isdigit(next_char(false)));

        if (negative)
            number = -number;
    }

    template <typename T, typename... Args>
    inline void read_int(T &number, Args &... args)
    {
        read_int(number);
        read_int(args...);
    }

    void _flush_output()
    {
        fwrite(output_buffer, sizeof(char), output_pos, stdout);
        output_pos = 0;
    }

    inline void write_char(char c)
    {
        if (output_pos == BUFFER_SIZE)
            _flush_output();

        output_buffer[output_pos++] = c;
    }

    template <typename T>
    inline void write_int(T number, char after = '\0')
    {
        if (number < 0)
        {
            write_char('-');
            number = -number;
        }
        int length = 0;
        while (number >= 10)
        {
            uint8_t lookup_value = lookup[number % 100];
            number /= 100;
            number_buffer[length++] = (lookup_value & 15) + '0';
            number_buffer[length++] = (lookup_value >> 4) + '0';
        }
        if (number != 0 || length == 0)
            write_char(number + '0');
        for (int i = length - 1; i >= 0; i--)
            write_char(number_buffer[i]);
        if (after)
            write_char(after);
    }
    void IOinit()
    {
        // Make sure _flush_output() is called at the end of the program.
        bool exit_success = atexit(_flush_output) == 0;
        assert(exit_success);
        for (int i = 0; i < 100; i++)
            lookup[i] = (i / 10 << 4) + i % 10;
    }
} // namespace IO

using namespace IO;

/* ---------------- typedefs ----------------*/
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

/* ---------------- utility functions ---------------- */

int dr[] = {0,1,-1,0,1,-1,1,-1};
int dc[] = {1,0,0,-1,1,-1,-1,1};
bool chk(int a, int b, int n, int m) {
        return 0 <= a && a < n && 0 <= b && b < m;
}

ll exp(ll n, ll m, ll md){
        ll a = 1;
        while (m > 0){
                if (m&1) a = (a * n%md) % md;
                m /= 2;
                n = (n*n) % md;
        }
        return a % md;
}

void disp(vi v){
        for(auto u:v)
                cout<<u<<" ";
        cout<<"\n";
}
void disp(vll v){
    for(auto u:v)
        cout<<u<<" ";
    cout<<endl;
}

int getSqr(int x){
        if(x < 0)
                return -1;
        int l = sqrt(x);
        for (int i = -2; i <= 2; ++i)
                if (l + i >= 0 && (l + i) * (l + i) == x)
                        return l;
        return -1;
}

const int NPRR = 1e7;
vi lp;
vector<int> prr;
void prfac(int n = NPRR){
        assert(n <= NPRR);
        lp.assign(n+1, 0);
        int i;
        for (i = 2;i <= n;++i) {
                if (lp[i] == 0) {
                        lp[i] = i;
                        prr.push_back(i);
                }
                for (int u: prr) {
                        if(i * u > n || u > lp[i]) break;
                        lp[i * u] = u;
                }
        }
}

bool check_composite_for_prime_function(ll n, ll a, ll d, int s){
        ll x = exp(a, d, n);
        if (x == 1 || x == n-1) return false;
        for(int r = 1;r < s;++r){
                x = x * x%n;
                x %= n;
                if(x == n-1) return false;
        }
        return true;
}
bool prime(ll n){
        if(n < 4) return n == 2 || n == 3;
        if (!(n&1)) return false;
        int s = 0;
        ll d = n-1;
        while(!(d&1)){
                d >>= 1;
                s++;
        }
        for(int a : {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37}){
                if(n == a) return true;
                if(check_composite_for_prime_function(n, a, d, s)) return false;
        }
        return true;
}

ll binomialCoeff(ll n, ll k)
{
    ll res = 1;

    // Since C(n, k) = C(n, n-k)
    if (k > n - k)
        k = n - k;

    // Calculate value of
    // [n * (n-1) *---* (n-k+1)] / [k * (k-1) *----* 1]
    for (ll i = 0; i < k; ++i) {
        res *= (n - i);
        res /= (i + 1);
    }

    return res;
}
/* custom hash for unordered map */
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
            // http://xorshift.di.unimi.it/splitmix64.c
            x += 0x9e3779b97f4a7c15;
            x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
            x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
            return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
            static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
            return splitmix64(x + FIXED_RANDOM);
    }
};

inline void read(int &x)
{
    scanf("%d", &x);
}

/* ---------------- constants ---------------- */
const ll MAXn=2e5 + 33,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=ll(1e15);

/* ---------------- start of code ---------------- */
vll last, mx;
int lk[MAXn];
int sz[MAXn];
int find(int s) {
    while(s != lk[s]) s = lk[s];
    return s;
}
void unite(int s, int r) {
    s = find(s);
    r = find(r);
    if(s == r) return;
    if(sz[s] < sz[r]) swap(s, r);
    lk[r] = s;
    sz[s] += sz[r];
}

void go1() {
    int n, q;cin >> n>> q;
    int a[n];
    last.assign(MAXn, -1);
    mx.assign(MAXn, 0);
    forn(i,MAXn) lk[i] = i;forn(i,MAXn) sz[i] = 1;
    //vll cnt(MAXn, 0);
    forn(i,n) {
        cin >> a[i];
//        cnt[a[i]]++;
        last[a[i]] = max(last[a[i]], i);
    }
    vll blk;
    int i = 0;
    while(i < n) {
        blk.PB(i);
        ll mxx = last[a[i]];
        int j = i;
        while(j < n and j <= mxx) {
            mxx = max(mxx, last[a[j]]);
            j++;
        }
        i=j;
    }
    blk.PB(n);
    ll sum = 0;
    forn(i, (int)blk.size() - 1) {
        // [blk[i], blk[i+1])
        map<int,int> cnt;
        ll mx = 0;
        forsn(j, blk[i], blk[i+1]) {
            ++cnt[a[j]];
            mx = max(mx, (ll)cnt[a[j]]);
        }
//        out3(blk[i], blk[i+1], mx);
        sum += mx;
    }
    cout << n - sum << ln;
}

int main(){
    fio;
    cout<<fixed<<setprecision(25);
    //cerr<<fixed<<setprecision(10);

    //freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);

    ll tt = 1;

/*

    cin >> tt;
    ll t = tt;

    //*/
    //forn(i, 100) cout << fac[i] << " ";

    auto start  = std::chrono::high_resolution_clock::now();

    while(tt--){
        //cout << "Case #" << t - tt << ": ";
        go1();
    }
    auto stop = std::chrono::high_resolution_clock::now();
    auto duration = std::chrono::duration_cast<std::chrono::nanoseconds>(stop - start);
    //cerr << "Time taken : " << ((long double)duration.count())/((long double) 1e9) <<"s "<< endl;
    return 0;
}
/* ---------------- end of code ---------------- */

//template <typename T>
//class fenwick {
//public:
//    vector<T> fenw;
//    int n;
//
//    fenwick(int _n) : n(_n) {
//        fenw.assign(n+1, 0);
//    }
//
//    void modify(int x, T v) {
//        while (x <= n) {
//            fenw[x] += v;
//            x += (x &-x);
//        }
//    }
//
//    T get(int x) {
//        T v{};
//        while (x > 0) {
//            v += fenw[x];
//            x -= (x & -x);
//        }
//        return v;
//    }
//
//    /*
//     * custom set
//     * modify(p, 1) to add p; p -> [1, n]
//     * ithpos(POS) to get POSth order statistics (POSth smallest element)
//     * pos -> [1, n]
//     */
//    int ithpos(int i) {
//        int low = 1, high = n;
//        while(low < high) {
//            int mid = (low + high) >> 1;
//            if(this->get(mid) >= i) {
//                high = mid;
//            } else {
//                low = mid + 1;
//            }
//        }
//        return low;
//    }
//
//};
//
//const int N = 2e5 + 33;
//int t[2*N];
//class segtree{
//public:
//    int n;
//
//    segtree(int _n) :n(_n) {}
//    void build() {
//        for(int i = n-1;i > 0;i--) t[i] = max(t[i<<1], t[i<<1|1]);
//    }
//
//    void modify(int pos, int val) {
//        for(t[pos += n] =  val; pos > 1;pos >>= 1) t[pos >> 1] = max(t[pos], t[pos^1]);
//    }
//
//    int query(int l, int r) {
//        int res = 0;
//        for(l += n, r += n;l < r;l>>=1, r>>=1) {
//            if(l&1) res = max(res, t[l++]);
//            if(r&1) res=  max(res, t[--r]);
//        }
//        return res;
//    }
//};
//
//vector<vi> ad;
//vi par;
//vi lev;
//void dfs(int s, int e, int level) {
//    par[s] = e;
//    lev[s] = level;
//    for(int u: ad[s]) {
//        if(u == e) continue;
//        dfs(u, s, level + 1);
//    }
//}
//set<int> sdia;
//
//pii dfs2(int s, int e, int level) {
//    int res = level;
//    int node = s;
//    for(int u:ad[s]) {
//        if(u == e) continue;
//        if(sdia.count(u)) continue;
//        pii ress = dfs2(u, s, level+1);
//        res = ress.F;
//        node = ress.S;
//    }
//    return {res, node};
//}
//void go2() {
//    int n;
//    cin >> n;
//    ad.assign(n, {});
//    forn(i,n-1) {
//        int r, s;
//        in2(r,s);
//        r--;s--;
//        ad[r].PB(s);
//        ad[s].PB(r);
//    }
//    par.assign(n, 0);
//    lev.assign(n, 0);
//    dfs(0,0,0);
//    int b, mx=0;
//    forn(i,n) {
//        if(lev[i] > mx) {
//            mx = lev[i];
//            b = i;
//        }
//    }
//    dfs(b, b, 0);
//    int c;
//    mx=0;
//    forn(i,n) {
//        if(lev[i] > mx) {
//            mx = lev[i];
//            c = i;
//        }
//    }
//    // b, c found
//    int p = c;
//    vi dia;
//    while(p != b) {
//        sdia.insert(p);
//        dia.PB(p);
//        p = par[p];
//    }
//    sdia.insert(b);
//    dia.PB(b);
//    int ans = (int)dia.size() - 1;
//    assert(ans <= 1e9+33 and ans >= 0);
//    mx = -1;
//    int node;
//    for(auto u: dia) {
//        pii l = dfs2(u, u, 0);
//        if(l.S == b or l.S == c) continue;
//        if(mx < l.F) {
//            mx = l.F;
//            node = l.S;
//        }
//    }
//    ans += mx;
//    cout << ans << ln;
//    out3(b+1, c+1, node+1);
//}


#pragma GCC target ("sse4.2")
#include<bits/stdc++.h>

using namespace std;

#define F first
#define S second
#define PB push_back
#define ln "\n"
#define forn(i,e) for(ll i=0; i<e; i++)
#define forsn(i,s,e) for(ll i=s; i<e; i++)
#define rforn(i,e) for(ll i=e; i>=0; i--)
#define rforsn(i,e,s) for(ll i=e; i>=s; i--)
#define vasort(v)         sort(v.begin(), v.end());
#define vdsort(v)         sort(v.begin(), v.end(),greater<ll>());
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define     mem(a,b)        memset(a,b,sizeof(a))
#define     sz(x)           ((int)size(x))
#define     EB              emplace_back
#define     flush           fflush(stdout)
#define out1(x1) cout << x1 << ln
#define out2(x1,x2) cout << x1 << " " << x2 << endl
#define out3(x1,x2,x3) cout << x1 << " " << x2 << " " << x3 << ln
#define out4(x1,x2,x3,x4) cout << x1 << " " << x2 << " " << x3 << " " << x4 << ln
#define all(d) d.begin(), d.end()
#define unordered_set(T) unordered_set<T, custom_hash>
#define unordered_map(T1, T2) unordered_map<T1, T2, custom_hash>

#define in1(x1) cin >> x1
#define in2(x1,x2) cin >> x1 >> x2
#define in3(x1,x2,x3) cin >> x1 >> x2 >> x3
#define in4(x1,x2,x3,x4) cin >> x1 >> x2 >> x3 >> x4

#define arrin(a, n) forn(i, n) cin >> a[i];
#define arrout(a,n) forn(i,n) {cout << a[i] << " ";} cout << ln;

/* ---------------- IO ----------------*/

namespace IO
{
    const int BUFFER_SIZE = 1 << 15;
    char input_buffer[BUFFER_SIZE];
    int input_pos = 0, input_len = 0;
    char output_buffer[BUFFER_SIZE];
    int output_pos = 0;
    char number_buffer[100];
    uint8_t lookup[100];
    void _update_input_buffer()
    {
        input_len = fread(input_buffer, sizeof(char), BUFFER_SIZE, stdin);
        input_pos = 0;
        if (input_len == 0)
            input_buffer[0] = EOF;
    }
    inline char next_char(bool advance = true)
    {
        if (input_pos >= input_len)
            _update_input_buffer();

        return input_buffer[advance ? input_pos++ : input_pos];
    }

    template <typename T>
    inline void read_int(T &number)
    {
        bool negative = false;
        number = 0;

        while (!isdigit(next_char(false)))
            if (next_char() == '-')
                negative = true;

        do
        {
            number = 10 * number + (next_char() - '0');
        } while (isdigit(next_char(false)));

        if (negative)
            number = -number;
    }

    template <typename T, typename... Args>
    inline void read_int(T &number, Args &... args)
    {
        read_int(number);
        read_int(args...);
    }

    void _flush_output()
    {
        fwrite(output_buffer, sizeof(char), output_pos, stdout);
        output_pos = 0;
    }

    inline void write_char(char c)
    {
        if (output_pos == BUFFER_SIZE)
            _flush_output();

        output_buffer[output_pos++] = c;
    }

    template <typename T>
    inline void write_int(T number, char after = '\0')
    {
        if (number < 0)
        {
            write_char('-');
            number = -number;
        }
        int length = 0;
        while (number >= 10)
        {
            uint8_t lookup_value = lookup[number % 100];
            number /= 100;
            number_buffer[length++] = (lookup_value & 15) + '0';
            number_buffer[length++] = (lookup_value >> 4) + '0';
        }
        if (number != 0 || length == 0)
            write_char(number + '0');
        for (int i = length - 1; i >= 0; i--)
            write_char(number_buffer[i]);
        if (after)
            write_char(after);
    }
    void IOinit()
    {
        // Make sure _flush_output() is called at the end of the program.
        bool exit_success = atexit(_flush_output) == 0;
        assert(exit_success);
        for (int i = 0; i < 100; i++)
            lookup[i] = (i / 10 << 4) + i % 10;
    }
} // namespace IO

using namespace IO;

/* ---------------- typedefs ----------------*/
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

/* ---------------- utility functions ---------------- */

int dr[] = {0,1,-1,0,1,-1,1,-1};
int dc[] = {1,0,0,-1,1,-1,-1,1};
bool chk(int a, int b, int n, int m) {
        return 0 <= a && a < n && 0 <= b && b < m;
}

ll exp(ll n, ll m, ll md){
        ll a = 1;
        while (m > 0){
                if (m&1) a = (a * n%md) % md;
                m /= 2;
                n = (n*n) % md;
        }
        return a % md;
}

void disp(vi v){
        for(auto u:v)
                cout<<u<<" ";
        cout<<"\n";
}
void disp(vll v){
    for(auto u:v)
        cout<<u<<" ";
    cout<<endl;
}

int getSqr(int x){
        if(x < 0)
                return -1;
        int l = sqrt(x);
        for (int i = -2; i <= 2; ++i)
                if (l + i >= 0 && (l + i) * (l + i) == x)
                        return l;
        return -1;
}

const int NPRR = 1e7;
vi lp;
vector<int> prr;
void prfac(int n = NPRR){
        assert(n <= NPRR);
        lp.assign(n+1, 0);
        int i;
        for (i = 2;i <= n;++i) {
                if (lp[i] == 0) {
                        lp[i] = i;
                        prr.push_back(i);
                }
                for (int u: prr) {
                        if(i * u > n || u > lp[i]) break;
                        lp[i * u] = u;
                }
        }
}

bool check_composite_for_prime_function(ll n, ll a, ll d, int s){
        ll x = exp(a, d, n);
        if (x == 1 || x == n-1) return false;
        for(int r = 1;r < s;++r){
                x = x * x%n;
                x %= n;
                if(x == n-1) return false;
        }
        return true;
}
bool prime(ll n){
        if(n < 4) return n == 2 || n == 3;
        if (!(n&1)) return false;
        int s = 0;
        ll d = n-1;
        while(!(d&1)){
                d >>= 1;
                s++;
        }
        for(int a : {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37}){
                if(n == a) return true;
                if(check_composite_for_prime_function(n, a, d, s)) return false;
        }
        return true;
}

ll binomialCoeff(ll n, ll k)
{
    ll res = 1;

    // Since C(n, k) = C(n, n-k)
    if (k > n - k)
        k = n - k;

    // Calculate value of
    // [n * (n-1) *---* (n-k+1)] / [k * (k-1) *----* 1]
    for (ll i = 0; i < k; ++i) {
        res *= (n - i);
        res /= (i + 1);
    }

    return res;
}
/* custom hash for unordered map */
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
            // http://xorshift.di.unimi.it/splitmix64.c
            x += 0x9e3779b97f4a7c15;
            x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
            x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
            return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
            static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
            return splitmix64(x + FIXED_RANDOM);
    }
};

inline void read(int &x)
{
    scanf("%d", &x);
}

/* ---------------- constants ---------------- */
const ll MAXn=1e5 + 33,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=ll(1e15);

/* ---------------- start of code ---------------- */
vll last, mx;
/*
 * Add this:
 * forn(i,<that n>) lk[i] = i;forn(i,n) sz[i] = 1;
 */

int lk[MAXn];
int sz[MAXn];
int find(int s) {
    while(s != lk[s]) s = lk[s];
    return s;
}
void unite(int s, int r) {
    s = find(s);
    r = find(r);
    if(s == r) return;
    if(sz[s] < sz[r]) swap(s, r);
    lk[r] = s;
    sz[s] += sz[r];
}

void go1() {
    int n, q;cin >> n>> q;
    int a[n];
    last.assign(MAXn, -1);
    mx.assign(MAXn, 0);
    forn(i,MAXn) lk[i] = i;forn(i,MAXn) sz[i] = 1;
    vll cnt(MAXn, 0);
    forn(i,n) {
        cin >> a[i];
        cnt[a[i]]++;
        last[a[i]] = max(last[a[i]], i);
    }
    int i = 0;
    while(i < n) {
        int j = i;
        while(j < n and j <= last[a[i]]) {
            unite(a[j], a[i]);
            j++;
        }
        i = j;
    }
    forn(i, n) {
        ll val = find(a[i]);
        mx[val] = max(mx[val], cnt[a[i]]);
    }
    ll sum = 0;
    forn(i, MAXn) sum += mx[i];
    cout << n - sum << ln;
}

int main(){
    fio;
    cout<<fixed<<setprecision(25);
    //cerr<<fixed<<setprecision(10);

    //freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);

    ll tt = 1;

/*

    cin >> tt;
    ll t = tt;

    //*/
    //forn(i, 100) cout << fac[i] << " ";

    auto start  = std::chrono::high_resolution_clock::now();

    while(tt--){
        //cout << "Case #" << t - tt << ": ";
        go1();
    }
    auto stop = std::chrono::high_resolution_clock::now();
    auto duration = std::chrono::duration_cast<std::chrono::nanoseconds>(stop - start);
    //cerr << "Time taken : " << ((long double)duration.count())/((long double) 1e9) <<"s "<< endl;
    return 0;
}
/* ---------------- end of code ---------------- */

//template <typename T>
//class fenwick {
//public:
//    vector<T> fenw;
//    int n;
//
//    fenwick(int _n) : n(_n) {
//        fenw.assign(n+1, 0);
//    }
//
//    void modify(int x, T v) {
//        while (x <= n) {
//            fenw[x] += v;
//            x += (x &-x);
//        }
//    }
//
//    T get(int x) {
//        T v{};
//        while (x > 0) {
//            v += fenw[x];
//            x -= (x & -x);
//        }
//        return v;
//    }
//
//    /*
//     * custom set
//     * modify(p, 1) to add p; p -> [1, n]
//     * ithpos(POS) to get POSth order statistics (POSth smallest element)
//     * pos -> [1, n]
//     */
//    int ithpos(int i) {
//        int low = 1, high = n;
//        while(low < high) {
//            int mid = (low + high) >> 1;
//            if(this->get(mid) >= i) {
//                high = mid;
//            } else {
//                low = mid + 1;
//            }
//        }
//        return low;
//    }
//
//};
//
//const int N = 2e5 + 33;
//int t[2*N];
//class segtree{
//public:
//    int n;
//
//    segtree(int _n) :n(_n) {}
//    void build() {
//        for(int i = n-1;i > 0;i--) t[i] = max(t[i<<1], t[i<<1|1]);
//    }
//
//    void modify(int pos, int val) {
//        for(t[pos += n] =  val; pos > 1;pos >>= 1) t[pos >> 1] = max(t[pos], t[pos^1]);
//    }
//
//    int query(int l, int r) {
//        int res = 0;
//        for(l += n, r += n;l < r;l>>=1, r>>=1) {
//            if(l&1) res = max(res, t[l++]);
//            if(r&1) res=  max(res, t[--r]);
//        }
//        return res;
//    }
//};
//
//vector<vi> ad;
//vi par;
//vi lev;
//void dfs(int s, int e, int level) {
//    par[s] = e;
//    lev[s] = level;
//    for(int u: ad[s]) {
//        if(u == e) continue;
//        dfs(u, s, level + 1);
//    }
//}
//set<int> sdia;
//
//pii dfs2(int s, int e, int level) {
//    int res = level;
//    int node = s;
//    for(int u:ad[s]) {
//        if(u == e) continue;
//        if(sdia.count(u)) continue;
//        pii ress = dfs2(u, s, level+1);
//        res = ress.F;
//        node = ress.S;
//    }
//    return {res, node};
//}
//void go2() {
//    int n;
//    cin >> n;
//    ad.assign(n, {});
//    forn(i,n-1) {
//        int r, s;
//        in2(r,s);
//        r--;s--;
//        ad[r].PB(s);
//        ad[s].PB(r);
//    }
//    par.assign(n, 0);
//    lev.assign(n, 0);
//    dfs(0,0,0);
//    int b, mx=0;
//    forn(i,n) {
//        if(lev[i] > mx) {
//            mx = lev[i];
//            b = i;
//        }
//    }
//    dfs(b, b, 0);
//    int c;
//    mx=0;
//    forn(i,n) {
//        if(lev[i] > mx) {
//            mx = lev[i];
//            c = i;
//        }
//    }
//    // b, c found
//    int p = c;
//    vi dia;
//    while(p != b) {
//        sdia.insert(p);
//        dia.PB(p);
//        p = par[p];
//    }
//    sdia.insert(b);
//    dia.PB(b);
//    int ans = (int)dia.size() - 1;
//    assert(ans <= 1e9+33 and ans >= 0);
//    mx = -1;
//    int node;
//    for(auto u: dia) {
//        pii l = dfs2(u, u, 0);
//        if(l.S == b or l.S == c) continue;
//        if(mx < l.F) {
//            mx = l.F;
//            node = l.S;
//        }
//    }
//    ans += mx;
//    cout << ans << ln;
//    out3(b+1, c+1, node+1);
//}


#pragma GCC target ("sse4.2")
#include<bits/stdc++.h>

using namespace std;

#define F first
#define S second
#define PB push_back
#define ln "\n"
#define forn(i,e) for(ll i=0; i<e; i++)
#define forsn(i,s,e) for(ll i=s; i<e; i++)
#define rforn(i,e) for(ll i=e; i>=0; i--)
#define rforsn(i,e,s) for(ll i=e; i>=s; i--)
#define vasort(v)         sort(v.begin(), v.end());
#define vdsort(v)         sort(v.begin(), v.end(),greater<ll>());
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define     mem(a,b)        memset(a,b,sizeof(a))
#define     sz(x)           ((int)size(x))
#define     EB              emplace_back
#define     flush           fflush(stdout)
#define out1(x1) cout << x1 << ln
#define out2(x1,x2) cout << x1 << " " << x2 << endl
#define out3(x1,x2,x3) cout << x1 << " " << x2 << " " << x3 << ln
#define out4(x1,x2,x3,x4) cout << x1 << " " << x2 << " " << x3 << " " << x4 << ln
#define all(d) d.begin(), d.end()
#define unordered_set(T) unordered_set<T, custom_hash>
#define unordered_map(T1, T2) unordered_map<T1, T2, custom_hash>

#define in1(x1) cin >> x1
#define in2(x1,x2) cin >> x1 >> x2
#define in3(x1,x2,x3) cin >> x1 >> x2 >> x3
#define in4(x1,x2,x3,x4) cin >> x1 >> x2 >> x3 >> x4

#define arrin(a, n) forn(i, n) cin >> a[i];
#define arrout(a,n) forn(i,n) {cout << a[i] << " ";} cout << ln;

/* ---------------- IO ----------------*/

namespace IO
{
    const int BUFFER_SIZE = 1 << 15;
    char input_buffer[BUFFER_SIZE];
    int input_pos = 0, input_len = 0;
    char output_buffer[BUFFER_SIZE];
    int output_pos = 0;
    char number_buffer[100];
    uint8_t lookup[100];
    void _update_input_buffer()
    {
        input_len = fread(input_buffer, sizeof(char), BUFFER_SIZE, stdin);
        input_pos = 0;
        if (input_len == 0)
            input_buffer[0] = EOF;
    }
    inline char next_char(bool advance = true)
    {
        if (input_pos >= input_len)
            _update_input_buffer();

        return input_buffer[advance ? input_pos++ : input_pos];
    }

    template <typename T>
    inline void read_int(T &number)
    {
        bool negative = false;
        number = 0;

        while (!isdigit(next_char(false)))
            if (next_char() == '-')
                negative = true;

        do
        {
            number = 10 * number + (next_char() - '0');
        } while (isdigit(next_char(false)));

        if (negative)
            number = -number;
    }

    template <typename T, typename... Args>
    inline void read_int(T &number, Args &... args)
    {
        read_int(number);
        read_int(args...);
    }

    void _flush_output()
    {
        fwrite(output_buffer, sizeof(char), output_pos, stdout);
        output_pos = 0;
    }

    inline void write_char(char c)
    {
        if (output_pos == BUFFER_SIZE)
            _flush_output();

        output_buffer[output_pos++] = c;
    }

    template <typename T>
    inline void write_int(T number, char after = '\0')
    {
        if (number < 0)
        {
            write_char('-');
            number = -number;
        }
        int length = 0;
        while (number >= 10)
        {
            uint8_t lookup_value = lookup[number % 100];
            number /= 100;
            number_buffer[length++] = (lookup_value & 15) + '0';
            number_buffer[length++] = (lookup_value >> 4) + '0';
        }
        if (number != 0 || length == 0)
            write_char(number + '0');
        for (int i = length - 1; i >= 0; i--)
            write_char(number_buffer[i]);
        if (after)
            write_char(after);
    }
    void IOinit()
    {
        // Make sure _flush_output() is called at the end of the program.
        bool exit_success = atexit(_flush_output) == 0;
        assert(exit_success);
        for (int i = 0; i < 100; i++)
            lookup[i] = (i / 10 << 4) + i % 10;
    }
} // namespace IO

using namespace IO;

/* ---------------- typedefs ----------------*/
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

/* ---------------- utility functions ---------------- */

int dr[] = {0,1,-1,0,1,-1,1,-1};
int dc[] = {1,0,0,-1,1,-1,-1,1};
bool chk(int a, int b, int n, int m) {
        return 0 <= a && a < n && 0 <= b && b < m;
}

ll exp(ll n, ll m, ll md){
        ll a = 1;
        while (m > 0){
                if (m&1) a = (a * n%md) % md;
                m /= 2;
                n = (n*n) % md;
        }
        return a % md;
}

void disp(vi v){
        for(auto u:v)
                cout<<u<<" ";
        cout<<"\n";
}
void disp(vll v){
    for(auto u:v)
        cout<<u<<" ";
    cout<<endl;
}

int getSqr(int x){
        if(x < 0)
                return -1;
        int l = sqrt(x);
        for (int i = -2; i <= 2; ++i)
                if (l + i >= 0 && (l + i) * (l + i) == x)
                        return l;
        return -1;
}

const int NPRR = 1e7;
vi lp;
vector<int> prr;
void prfac(int n = NPRR){
        assert(n <= NPRR);
        lp.assign(n+1, 0);
        int i;
        for (i = 2;i <= n;++i) {
                if (lp[i] == 0) {
                        lp[i] = i;
                        prr.push_back(i);
                }
                for (int u: prr) {
                        if(i * u > n || u > lp[i]) break;
                        lp[i * u] = u;
                }
        }
}

bool check_composite_for_prime_function(ll n, ll a, ll d, int s){
        ll x = exp(a, d, n);
        if (x == 1 || x == n-1) return false;
        for(int r = 1;r < s;++r){
                x = x * x%n;
                x %= n;
                if(x == n-1) return false;
        }
        return true;
}
bool prime(ll n){
        if(n < 4) return n == 2 || n == 3;
        if (!(n&1)) return false;
        int s = 0;
        ll d = n-1;
        while(!(d&1)){
                d >>= 1;
                s++;
        }
        for(int a : {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37}){
                if(n == a) return true;
                if(check_composite_for_prime_function(n, a, d, s)) return false;
        }
        return true;
}

ll binomialCoeff(ll n, ll k)
{
    ll res = 1;

    // Since C(n, k) = C(n, n-k)
    if (k > n - k)
        k = n - k;

    // Calculate value of
    // [n * (n-1) *---* (n-k+1)] / [k * (k-1) *----* 1]
    for (ll i = 0; i < k; ++i) {
        res *= (n - i);
        res /= (i + 1);
    }

    return res;
}
/* custom hash for unordered map */
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
            // http://xorshift.di.unimi.it/splitmix64.c
            x += 0x9e3779b97f4a7c15;
            x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
            x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
            return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
            static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
            return splitmix64(x + FIXED_RANDOM);
    }
};

inline void read(int &x)
{
    scanf("%d", &x);
}

/* ---------------- constants ---------------- */
const ll MAXn=2e5 + 33,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=ll(1e15);

/* ---------------- start of code ---------------- */
vll last, mx;
int lk[MAXn];
int sz[MAXn];
int find(int s) {
    while(s != lk[s]) s = lk[s];
    return s;
}
void unite(int s, int r) {
    s = find(s);
    r = find(r);
    if(s == r) return;
    if(sz[s] < sz[r]) swap(s, r);
    lk[r] = s;
    sz[s] += sz[r];
}

void go1() {
    int n, q;cin >> n>> q;
    int a[n];
    last.assign(MAXn, -1);
    mx.assign(MAXn, 0);
    forn(i,MAXn) lk[i] = i;forn(i,MAXn) sz[i] = 1;
    //vll cnt(MAXn, 0);
    forn(i,n) {
        cin >> a[i];
//        cnt[a[i]]++;
        last[a[i]] = max(last[a[i]], i);
    }
    vll blk;
    int i = 0;
    while(i < n) {
        blk.PB(i);
        i = last[a[i]] + 1;
    }
    blk.PB(n);
    ll sum = 0;
    forn(i, (int)blk.size() - 1) {
        // [blk[i], blk[i+1])
        map<int,int> cnt;
        ll mx = 0;
        forsn(j, blk[i], blk[i+1]) {
            ++cnt[a[j]];
            mx = max(mx, (ll)cnt[a[j]]);
        }
//        out3(blk[i], blk[i+1], mx);
        sum += mx;
    }
    cout << n - sum << ln;
}

int main(){
    fio;
    cout<<fixed<<setprecision(25);
    //cerr<<fixed<<setprecision(10);

    //freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);

    ll tt = 1;

/*

    cin >> tt;
    ll t = tt;

    //*/
    //forn(i, 100) cout << fac[i] << " ";

    auto start  = std::chrono::high_resolution_clock::now();

    while(tt--){
        //cout << "Case #" << t - tt << ": ";
        go1();
    }
    auto stop = std::chrono::high_resolution_clock::now();
    auto duration = std::chrono::duration_cast<std::chrono::nanoseconds>(stop - start);
    //cerr << "Time taken : " << ((long double)duration.count())/((long double) 1e9) <<"s "<< endl;
    return 0;
}
/* ---------------- end of code ---------------- */

//template <typename T>
//class fenwick {
//public:
//    vector<T> fenw;
//    int n;
//
//    fenwick(int _n) : n(_n) {
//        fenw.assign(n+1, 0);
//    }
//
//    void modify(int x, T v) {
//        while (x <= n) {
//            fenw[x] += v;
//            x += (x &-x);
//        }
//    }
//
//    T get(int x) {
//        T v{};
//        while (x > 0) {
//            v += fenw[x];
//            x -= (x & -x);
//        }
//        return v;
//    }
//
//    /*
//     * custom set
//     * modify(p, 1) to add p; p -> [1, n]
//     * ithpos(POS) to get POSth order statistics (POSth smallest element)
//     * pos -> [1, n]
//     */
//    int ithpos(int i) {
//        int low = 1, high = n;
//        while(low < high) {
//            int mid = (low + high) >> 1;
//            if(this->get(mid) >= i) {
//                high = mid;
//            } else {
//                low = mid + 1;
//            }
//        }
//        return low;
//    }
//
//};
//
//const int N = 2e5 + 33;
//int t[2*N];
//class segtree{
//public:
//    int n;
//
//    segtree(int _n) :n(_n) {}
//    void build() {
//        for(int i = n-1;i > 0;i--) t[i] = max(t[i<<1], t[i<<1|1]);
//    }
//
//    void modify(int pos, int val) {
//        for(t[pos += n] =  val; pos > 1;pos >>= 1) t[pos >> 1] = max(t[pos], t[pos^1]);
//    }
//
//    int query(int l, int r) {
//        int res = 0;
//        for(l += n, r += n;l < r;l>>=1, r>>=1) {
//            if(l&1) res = max(res, t[l++]);
//            if(r&1) res=  max(res, t[--r]);
//        }
//        return res;
//    }
//};
//
//vector<vi> ad;
//vi par;
//vi lev;
//void dfs(int s, int e, int level) {
//    par[s] = e;
//    lev[s] = level;
//    for(int u: ad[s]) {
//        if(u == e) continue;
//        dfs(u, s, level + 1);
//    }
//}
//set<int> sdia;
//
//pii dfs2(int s, int e, int level) {
//    int res = level;
//    int node = s;
//    for(int u:ad[s]) {
//        if(u == e) continue;
//        if(sdia.count(u)) continue;
//        pii ress = dfs2(u, s, level+1);
//        res = ress.F;
//        node = ress.S;
//    }
//    return {res, node};
//}
//void go2() {
//    int n;
//    cin >> n;
//    ad.assign(n, {});
//    forn(i,n-1) {
//        int r, s;
//        in2(r,s);
//        r--;s--;
//        ad[r].PB(s);
//        ad[s].PB(r);
//    }
//    par.assign(n, 0);
//    lev.assign(n, 0);
//    dfs(0,0,0);
//    int b, mx=0;
//    forn(i,n) {
//        if(lev[i] > mx) {
//            mx = lev[i];
//            b = i;
//        }
//    }
//    dfs(b, b, 0);
//    int c;
//    mx=0;
//    forn(i,n) {
//        if(lev[i] > mx) {
//            mx = lev[i];
//            c = i;
//        }
//    }
//    // b, c found
//    int p = c;
//    vi dia;
//    while(p != b) {
//        sdia.insert(p);
//        dia.PB(p);
//        p = par[p];
//    }
//    sdia.insert(b);
//    dia.PB(b);
//    int ans = (int)dia.size() - 1;
//    assert(ans <= 1e9+33 and ans >= 0);
//    mx = -1;
//    int node;
//    for(auto u: dia) {
//        pii l = dfs2(u, u, 0);
//        if(l.S == b or l.S == c) continue;
//        if(mx < l.F) {
//            mx = l.F;
//            node = l.S;
//        }
//    }
//    ans += mx;
//    cout << ans << ln;
//    out3(b+1, c+1, node+1);
//}


#include <bits/stdc++.h>

#define fast ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define endl '\n'
#define ll long long

using namespace std;

int main()
{
    fast;
    //freopen("input.txt", "r", stdin);
    int n,q;
    cin >> n >> q;
    vector<int> arr(n);
    int m = 0;
    for(int i = 0 ; i < n;i++){
        cin >> arr[i];
        m = max(m,arr[i]);
    }
    vector<pair<int,int>> g(m+1);
    for(int i = 0; i < m+1;i++){
        g[i].first = 1e9;
    }
    vector<bool> ban(m+1);
    for(int i = 0; i < n;i++){
        g[arr[i]].first = min(g[arr[i]].first,i);
        g[arr[i]].second = max(g[arr[i]].second,i);
    }
    for(int i = 0 ; i < n;i++){
        if(g[arr[i]].first == i){
            int next = i;
            bool baned = true;
            for(int j = i+1; j < g[arr[i]].second;j++){
                next = j;
                if(arr[j] != arr[i]){
                    baned = false;
                    break;
                }

            }
            if(baned){
                ban[arr[i]] = true;
            }
            i = next-1;
        }
    }
    int cost = 0;
    for(int i = 0; i < n;i++){
        int r = g[arr[i]].second;
        int maxR = r;
        int j = i+1;
        while (j < maxR){
            maxR = max(maxR,g[arr[j]].second);
            j++;
        }
        map<int,int> stat;
        int cnt = maxR-i+1;
        for(int l = i; l <= maxR;l++){
            if(ban[arr[l]]){
                cnt--;
                continue;
            }
            stat[arr[l]]++;
        }
        int maxCnt = 0;
        for(auto to:stat){
            maxCnt = max(maxCnt,to.second);
        }
        cost += cnt - maxCnt;
        i = maxR + 1;
    }
    cout << cost << endl;
    /* stuff you should look for
        * int overflow, array bounds
        * special cases (n=1?), set tle
        * do smth instead of nothing and stay organized
    */
    return 0;
}


#include <bits/stdc++.h>

#define fast ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define endl '\n'
#define ll long long

using namespace std;

int main()
{
    fast;
    //freopen("input.txt", "r", stdin);
    int n,q;
    cin >> n >> q;
    vector<int> arr(n);
    int m = 0;
    for(int i = 0 ; i < n;i++){
        cin >> arr[i];
        m = max(m,arr[i]);
    }
    vector<pair<int,int>> g(m+1);
    for(int i = 0; i < m+1;i++){
        g[i].first = 1e9;
    }
    for(int i = 0; i < n;i++){
        g[arr[i]].first = min(g[arr[i]].first,i);
        g[arr[i]].second = max(g[arr[i]].second,i);
    }
    int cost = 0;
    for(int i = 0; i < n;i++){
        int r = g[arr[i]].second;
        int maxR = r;
        int j = i+1;
        while (j < maxR){
            maxR = max(maxR,g[arr[j]].second);
            j++;
        }
        map<int,int> stat;
        for(int l = i; l <= maxR;l++){
            stat[arr[l]]++;
        }
        int maxCnt = 0;
        for(auto to:stat){
            maxCnt = max(maxCnt,to.second);
        }
        cost += (maxR-i+1) - maxCnt;
        i = maxR;
    }
    cout << cost << endl;
    /* stuff you should look for
        * int overflow, array bounds
        * special cases (n=1?), set tle
        * do smth instead of nothing and stay organized
    */
    return 0;
}


#include <bits/stdc++.h>

#define fast ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define endl '\n'
#define ll long long

using namespace std;

int main()
{
    fast;
    //freopen("input.txt", "r", stdin);
    int n,q;
    cin >> n >> q;
    vector<int> arr(n);
    int m = 0;
    for(int i = 0 ; i < n;i++){
        cin >> arr[i];
        m = max(m,arr[i]);
    }
    vector<pair<int,int>> g(m+1);
    for(int i = 0; i < n;i++){
        g[arr[i]].first = min(g[arr[i]].first,i);
        g[arr[i]].second = max(g[arr[i]].second,i);
    }
    int cost = 0;
    for(int i = 0; i < n;i++){
        int r = g[arr[i]].second;
        int maxR = r;
        int j = i+1;
        while (j < maxR){
            maxR = max(maxR,g[arr[j]].second);
            j++;
        }
        map<int,int> stat;
        for(int l = i; l <= maxR;l++){
            stat[arr[l]]++;
        }
        int maxCnt = 0;
        for(auto to:stat){
            maxCnt = max(maxCnt,to.second);
        }
        cost += (maxR-i+1) - maxCnt;
        i = maxR + 1;
    }
    cout << cost << endl;
    /* stuff you should look for
        * int overflow, array bounds
        * special cases (n=1?), set tle
        * do smth instead of nothing and stay organized
    */
    return 0;
}


#include <bits/stdc++.h>

#define fast ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define endl '\n'
#define ll long long

using namespace std;

int main()
{
    fast;
    //freopen("input.txt", "r", stdin);
    int n,q;
    cin >> n >> q;
    vector<int> arr(n);
    int m = 0;
    for(int i = 0 ; i < n;i++){
        cin >> arr[i];
        m = max(m,arr[i]);
    }
    vector<pair<int,int>> g(m+1);
    for(int i = 0; i < m+1;i++){
        g[i].first = 1e9;
    }
    for(int i = 0; i < n;i++){
        g[arr[i]].first = min(g[arr[i]].first,i);
        g[arr[i]].second = max(g[arr[i]].second,i);
    }
    int cost = 0;
    for(int i = 0; i < n;i++){
        int r = g[arr[i]].second;
        int maxR = r;
        int j = i+1;
        while (j < maxR){
            maxR = max(maxR,g[arr[j]].second);
            j++;
        }
        map<int,int> stat;
        for(int l = i; l <= maxR;l++){
            stat[arr[l]]++;
        }
        int maxCnt = 0;
        for(auto to:stat){
            maxCnt = max(maxCnt,to.second);
        }
        cost += (maxR-i+1) - maxCnt;
        i = maxR + 1;
    }
    cout << cost << endl;
    /* stuff you should look for
        * int overflow, array bounds
        * special cases (n=1?), set tle
        * do smth instead of nothing and stay organized
    */
    return 0;
}


//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")
//#pragma GCC optimize("unroll-loops")
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <random>

#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define mp make_pair
#define input freopen("input.txt","r",stdin);
#define output freopen("output.txt","w",stdout);
#define fast_io ios::sync_with_stdio(NULL), cin.tie(NULL), cout.tie(NULL);
#define fix cout << fixed << setprecision(15);
//#define left left228
//#define right right228
//#define next next228
#define rank rank228
//#define prev prev228
#define y1 y1228
#define dout if(debug) cout
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int> ;
using pll = pair<ll, ll>;
using pci = pair<char, int>;
using vi = vector<int> ;
using vll = vector<ll> ;
using vpii = vector<pii> ;
const ll infll = 1e18 + 3;
const int maxn = 1e6 + 77;
const int nmax = 1e6 + 577;
const ll basell = 1e18 + 3;
//const int mod = 1e9 + 7;
const ld eps = 1e-7;
const int inf = 1009000999;
const int nv = 100505;
const int baseint = 1000200013;
const ld PI = acos(-1.0);
inline bool EQ(ld a, ld b) { return fabs(a-b) < 1e-9; }
inline bool IF(int a, int b, int c) { return (a >= b && a <= c); }
inline bool IFS(int a, int b, int c) { return (a > b && a < c); }
template<typename T> inline istream &operator>> (istream &_in, vector<T> &_v) { for (auto &_i : _v) { _in >> _i; } return _in; }
//mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
//typedef pair<int, int> pt;
//#define x first
//#define y second
//ifstream cin("input.txt");
//ofstream cout("output.txt");
/*
sort(a, a + n, [&](pair<pt, int> a, pair<pt, int> b){if (a.x.x != b.x.x)
        return a.x.x < b.x.x; return a.x.y > b.x.y;});
for(int c : s)
for(int &i : a) cin >> i;
for(int c = 'a'; c <= 'z'; ++c)
vector<vector<ll>> dp(n, vector<ll>(n+2));
__int128;
char 0 = int 48;
char c = cin;
int h = (int)c - 48;
*/

/*char memory[(int)1e8];

char memorypos;

inline void * operator new(size_t n){
    char * ret = memory + memorypos;
    memorypos += n;
    return (void *)ret;
}

inline void operator delete(void *){}
*/

int rank[maxn];
int parent[maxn];

pii b[2 * nv];

void make_set (int v) {
    if(parent[v] == 0) {
        b[v] = {inf, 0};
    }
    parent[v] = v;
    rank[v] = 0;
}

int find_set (int v) {
    if (v == parent[v])
        return v;
    return parent[v] = find_set (parent[v]);
}

void union_sets (int a, int b) {
    a = find_set (a);
    b = find_set (b);
    if (a != b) {
        if (rank[a] < rank[b])
            swap (a, b);
        parent[b] = a;
        if (rank[a] == rank[b])
            ++rank[a];
    }
}

int a[2 * nv];

int h[2 * nv];

int inline solve() {
    //input;output;
    //fix;
    fast_io
    int n, qss;
    cin >> n >> qss;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        make_set(a[i]);
        h[a[i]]++;
        b[a[i]].fi = min(b[i].fi, i);
        b[a[i]].se = max(b[i].se, i);
    }
    int ans = 0;
    int c = a[0], d = b[a[0]].se, mx = 0;
    for (int i = 1; i < n; ++i) {
        if(d < i) {
            c = a[i], d = b[a[i]].se;
            mx = h[a[i]];
        } else {
            if(find_set(c) != find_set(a[i])) {
                ans += min(mx, h[a[i]]);
                mx = max(mx, h[a[i]]);
            }
            union_sets(a[i], c);
            d = max(d, b[a[i]].se);
        }
    }
    cout << ans;
    return 0;
}
int32_t main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    solve();
    return 0;
}
/*
1
13
61468978999999
 * */


//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")
//#pragma GCC optimize("unroll-loops")
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <random>

#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define mp make_pair
#define input freopen("input.txt","r",stdin);
#define output freopen("output.txt","w",stdout);
#define fast_io ios::sync_with_stdio(NULL), cin.tie(NULL), cout.tie(NULL);
#define fix cout << fixed << setprecision(15);
//#define left left228
//#define right right228
//#define next next228
#define rank rank228
//#define prev prev228
#define y1 y1228
#define dout if(debug) cout
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int> ;
using pll = pair<ll, ll>;
using pci = pair<char, int>;
using vi = vector<int> ;
using vll = vector<ll> ;
using vpii = vector<pii> ;
const ll infll = 1e18 + 3;
const int maxn = 1e6 + 77;
const int nmax = 1e6 + 577;
const ll basell = 1e18 + 3;
//const int mod = 1e9 + 7;
const ld eps = 1e-7;
const int inf = 1009000999;
const int nv = 100505;
const int baseint = 1000200013;
const ld PI = acos(-1.0);
inline bool EQ(ld a, ld b) { return fabs(a-b) < 1e-9; }
inline bool IF(int a, int b, int c) { return (a >= b && a <= c); }
inline bool IFS(int a, int b, int c) { return (a > b && a < c); }
template<typename T> inline istream &operator>> (istream &_in, vector<T> &_v) { for (auto &_i : _v) { _in >> _i; } return _in; }
//mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
//typedef pair<int, int> pt;
//#define x first
//#define y second
//ifstream cin("input.txt");
//ofstream cout("output.txt");
/*
sort(a, a + n, [&](pair<pt, int> a, pair<pt, int> b){if (a.x.x != b.x.x)
        return a.x.x < b.x.x; return a.x.y > b.x.y;});
for(int c : s)
for(int &i : a) cin >> i;
for(int c = 'a'; c <= 'z'; ++c)
vector<vector<ll>> dp(n, vector<ll>(n+2));
__int128;
char 0 = int 48;
char c = cin;
int h = (int)c - 48;
*/

/*char memory[(int)1e8];

char memorypos;

inline void * operator new(size_t n){
    char * ret = memory + memorypos;
    memorypos += n;
    return (void *)ret;
}

inline void operator delete(void *){}
*/

int rank[maxn];
int parent[maxn];

pii b[2 * nv];

void make_set (int v) {
    if(parent[v] == 0) {
        b[v] = {inf, 0};
    }
    parent[v] = v;
    rank[v] = 0;
}

int find_set (int v) {
    if (v == parent[v])
        return v;
    return parent[v] = find_set (parent[v]);
}

void union_sets (int a, int b) {
    a = find_set (a);
    b = find_set (b);
    if (a != b) {
        if (rank[a] < rank[b])
            swap (a, b);
        parent[b] = a;
        if (rank[a] == rank[b])
            ++rank[a];
    }
}

int a[2 * nv];

int h[2 * nv];

int inline solve() {
    //input;output;
    //fix;
    fast_io
    int n, qss;
    cin >> n >> qss;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        make_set(a[i]);
        h[a[i]]++;
        b[a[i]].fi = min(b[i].fi, i);
        b[a[i]].se = max(b[i].se, i);
    }
    int ans = 0;
    int c = a[0], d = b[a[0]].se;
    for (int i = 1; i < n; ++i) {
        if(d < i) {
            c = a[i], d = b[a[i]].se;
        } else {
            if(find_set(c) != find_set(a[i]))ans += min(h[c], h[a[i]]);
            union_sets(a[i], c);
            d = max(d, b[a[i]].se);
        }
    }
    cout << ans;
    return 0;
}
int32_t main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    solve();
    return 0;
}
/*
1
13
61468978999999
 * */


//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")
//#pragma GCC optimize("unroll-loops")
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <random>

#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define mp make_pair
#define input freopen("input.txt","r",stdin);
#define output freopen("output.txt","w",stdout);
#define fast_io ios::sync_with_stdio(NULL), cin.tie(NULL), cout.tie(NULL);
#define fix cout << fixed << setprecision(15);
//#define left left228
//#define right right228
//#define next next228
#define rank rank228
//#define prev prev228
#define y1 y1228
#define dout if(debug) cout
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int> ;
using pll = pair<ll, ll>;
using pci = pair<char, int>;
using vi = vector<int> ;
using vll = vector<ll> ;
using vpii = vector<pii> ;
const ll infll = 1e18 + 3;
const int maxn = 1e6 + 77;
const int nmax = 1e6 + 577;
const ll basell = 1e18 + 3;
//const int mod = 1e9 + 7;
const ld eps = 1e-7;
const int inf = 1009000999;
const int nv = 100505;
const int baseint = 1000200013;
const ld PI = acos(-1.0);
inline bool EQ(ld a, ld b) { return fabs(a-b) < 1e-9; }
inline bool IF(int a, int b, int c) { return (a >= b && a <= c); }
inline bool IFS(int a, int b, int c) { return (a > b && a < c); }
template<typename T> inline istream &operator>> (istream &_in, vector<T> &_v) { for (auto &_i : _v) { _in >> _i; } return _in; }
//mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
//typedef pair<int, int> pt;
//#define x first
//#define y second
//ifstream cin("input.txt");
//ofstream cout("output.txt");
/*
sort(a, a + n, [&](pair<pt, int> a, pair<pt, int> b){if (a.x.x != b.x.x)
        return a.x.x < b.x.x; return a.x.y > b.x.y;});
for(int c : s)
for(int &i : a) cin >> i;
for(int c = 'a'; c <= 'z'; ++c)
vector<vector<ll>> dp(n, vector<ll>(n+2));
__int128;
char 0 = int 48;
char c = cin;
int h = (int)c - 48;
*/

/*char memory[(int)1e8];

char memorypos;

inline void * operator new(size_t n){
    char * ret = memory + memorypos;
    memorypos += n;
    return (void *)ret;
}

inline void operator delete(void *){}
*/

int rank[maxn];
int parent[maxn];

pii b[2 * nv];

void make_set (int v) {
    if(parent[v] == 0) {
        b[v] = {inf, 0};
    }
    parent[v] = v;
    rank[v] = 0;
}

int find_set (int v) {
    if (v == parent[v])
        return v;
    return parent[v] = find_set (parent[v]);
}

void union_sets (int a, int b) {
    a = find_set (a);
    b = find_set (b);
    if (a != b) {
        if (rank[a] < rank[b])
            swap (a, b);
        parent[b] = a;
        if (rank[a] == rank[b])
            ++rank[a];
    }
}

int a[2 * nv];

int h[2 * nv];

int inline solve() {
    //input;output;
    //fix;
    fast_io
    int n, qss;
    cin >> n >> qss;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        make_set(a[i]);
        h[a[i]]++;
        b[a[i]].fi = min(b[i].fi, i);
        b[a[i]].se = max(b[i].se, i);
    }
    int ans = 0;
    int c = a[0], d = b[a[0]].se, mx = h[a[0]];
    for (int i = 1; i < n; ++i) {
        if(d < i) {
            c = a[i], d = b[a[i]].se;
            mx = h[a[i]];
        } else {
            if(find_set(c) != find_set(a[i])) {
                ans += min(mx, h[a[i]]);
                mx = max(mx, h[a[i]]);
            }
            union_sets(a[i], c);
            d = max(d, b[a[i]].se);
        }
    }
    cout << ans;
    return 0;
}
int32_t main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    solve();
    return 0;
}
/*
1
13
61468978999999
 * */


#pragma GCC optimize(2)
#include <cstdio>
#include <queue>
#include <string>
#include <cstring>
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <fstream>
#include <cassert>
#include <complex>
#include <ctime>
#include <tr1/unordered_map>
#include <bitset>

using namespace std;
using namespace tr1;
typedef long long ll;
inline int read()
{
    int x = 0;
    int f = 0;
    char ch = 0;
    while(!isdigit(ch))
    {
        f |= (ch == '-') ? 1 : 0;
        ch = getchar();
    }
    while(isdigit(ch))
    {
        x = (x << 3) + (x << 1) + (ch ^ 48);
        ch = getchar();
    }
    return f ? -x : x;
}

const int INF = 1e9;
const int maxn = 2e5 + 10;
int n,q;
int sum[maxn << 2];
int vis[maxn];
int lz[maxn << 2];
int last1[maxn],last2[maxn];
int aa[maxn];

inline void pushdown(int rt)
{
    if(lz[rt] != -INF)
    {
        lz[rt << 1] = lz[rt];
        lz[rt << 1 | 1] = lz[rt];
        sum[rt << 1] = lz[rt];
        sum[rt << 1 | 1] = lz[rt];
        lz[rt] = -INF;
    }
}

inline void build(int rt,int l,int r)
{
    sum[rt] = -INF;
    lz[rt] = -INF;
    if(l == r)
    {
        return ;
    }
    int mid = (l + r) >> 1;
    build(rt << 1,l,mid);
    build(rt << 1 | 1,mid + 1,r);
}

inline void update(int rt,int l,int r,int al,int ar,int k)
{
    if(l > ar || r < al)
        return ;
    if(l <= al && r >= ar)
    {
        sum[rt] = k;
        lz[rt] = k;
        return ;
    }
    pushdown(rt);
    int mid = (al + ar) >> 1;
    update(rt << 1,l,r,al,mid,k);
    update(rt << 1 | 1,l,r,mid + 1,ar,k);
    sum[rt] = max(sum[rt << 1],sum[rt << 1 | 1]);
}

inline int query(int rt,int l,int r,int al,int ar)
{
    if(l > ar || r < al)
        return -INF;
    if(l <= al && r >= ar)
        return sum[rt];
    pushdown(rt);
    int mid = (al + ar) >> 1;
    return max(query(rt << 1,l,r,al,mid),query(rt << 1 | 1,l,r,mid + 1,ar));
}

int main()
{
    n = read();
    q = read();
    for(int i = 1; i <= n; ++i)
        aa[i] = read(),++vis[aa[i]];
    build(1,1,n);
    for(int i = 1; i <= n; ++i)
        last2[aa[i]] = i;
    for(int i = n; i >= 1; --i)
        last1[aa[i]] = i;
    for(int i = 1; i <= 200000; ++i)
    {
        if(last1[i] && last1[i] < last2[i])
        {
            update(1,last1[i],last2[i] - 1,1,n,0);
            update(1,last1[i],last1[i],1,n,vis[i]);
        }
    }
    int cur = 0;
    int ans = 0;
    for(int i = 1; i <= n; ++i)
        if(query(1,i,i,1,n) == -INF)
        {
            if(i == cur + 1)
            {
                cur = i;
                continue;
            }
            int tmp = query(1,cur + 1,i - 1,1,n);
            ans += i - cur - tmp;
            cur = i;
        }
    printf("%d",ans);
}


#pragma GCC optimize(2)
#include <cstdio>
#include <queue>
#include <string>
#include <cstring>
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <fstream>
#include <cassert>
#include <complex>
#include <ctime>
#include <tr1/unordered_map>
#include <bitset>

using namespace std;
using namespace tr1;
typedef long long ll;
inline int read()
{
    int x = 0;
    int f = 0;
    char ch = 0;
    while(!isdigit(ch))
    {
        f |= (ch == '-') ? 1 : 0;
        ch = getchar();
    }
    while(isdigit(ch))
    {
        x = (x << 3) + (x << 1) + (ch ^ 48);
        ch = getchar();
    }
    return f ? -x : x;
}

const int INF = 1e9;
const int maxn = 2e5 + 10;
int n,q;
int sum[maxn << 2];
int vis[maxn];
int lz[maxn << 2];
int last1[maxn],last2[maxn];
int aa[maxn];

inline void pushdown(int rt)
{
    if(lz[rt] != -INF)
    {
        lz[rt << 1] = lz[rt];
        lz[rt << 1 | 1] = lz[rt];
        sum[rt << 1] = lz[rt];
        sum[rt << 1 | 1] = lz[rt];
        lz[rt] = -INF;
    }
}

inline void build(int rt,int l,int r)
{
    sum[rt] = -INF;
    lz[rt] = -INF;
    if(l == r)
    {
        return ;
    }
    int mid = (l + r) >> 1;
    build(rt << 1,l,mid);
    build(rt << 1 | 1,mid + 1,r);
}

inline void update(int rt,int l,int r,int al,int ar,int k)
{
    if(l > ar || r < al)
        return ;
    if(l <= al && r >= ar)
    {
        sum[rt] = k;
        lz[rt] = k;
        return ;
    }
    pushdown(rt);
    int mid = (al + ar) >> 1;
    update(rt << 1,l,r,al,mid,k);
    update(rt << 1 | 1,l,r,mid + 1,ar,k);
    sum[rt] = max(sum[rt << 1],sum[rt << 1 | 1]);
}

inline int query(int rt,int l,int r,int al,int ar)
{
    if(l > ar || r < al)
        return -INF;
    if(l <= al && r >= ar)
        return sum[rt];
    pushdown(rt);
    int mid = (al + ar) >> 1;
    return max(query(rt << 1,l,r,al,mid),query(rt << 1 | 1,l,r,mid + 1,ar));
}

int main()
{
    n = read();
    q = read();
    for(int i = 1; i <= n; ++i)
        aa[i] = read(),++vis[aa[i]];
    build(1,1,n);
    for(int i = 1; i <= n; ++i)
        last2[aa[i]] = i;
    for(int i = n; i >= 1; --i)
        last1[aa[i]] = i;
    for(int i = 1; i <= 200000; ++i)
    {
        if(last1[i] && last1[i] < last2[i])
        {
            update(1,last1[i],last2[i] - 1,1,n,0);
        }
    }
    for(int i = 1; i <= 200000; ++i)
    {
        if(last1[i] && last1[i] < last2[i])
        {
            update(1,last1[i],last1[i],1,n,vis[i]);
        }
    }
    int cur = 0;
    int ans = 0;
    for(int i = 1; i <= n; ++i)
        if(query(1,i,i,1,n) == -INF)
        {
            if(i == cur + 1)
            {
                cur = i;
                continue;
            }
            int tmp = query(1,cur + 1,i - 1,1,n);
            ans += i - cur - tmp;
            cur = i;
        }
    printf("%d",ans);
}


#pragma GCC optimize(2)
#include <cstdio>
#include <queue>
#include <string>
#include <cstring>
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <fstream>
#include <cassert>
#include <complex>
#include <ctime>
#include <tr1/unordered_map>
#include <bitset>

using namespace std;
using namespace tr1;
typedef long long ll;
inline int read()
{
    int x = 0;
    int f = 0;
    char ch = 0;
    while(!isdigit(ch))
    {
        f |= (ch == '-') ? 1 : 0;
        ch = getchar();
    }
    while(isdigit(ch))
    {
        x = (x << 3) + (x << 1) + (ch ^ 48);
        ch = getchar();
    }
    return f ? -x : x;
}

const int INF = 1e9;
const int maxn = 2e5 + 10;
int n,q;
int sum[maxn << 2];
int vis[maxn];
int lz[maxn << 2];
int last1[maxn],last2[maxn];
int aa[maxn];

inline void pushdown(int rt)
{
    if(lz[rt] != -INF)
    {
        lz[rt << 1] = lz[rt];
        lz[rt << 1 | 1] = lz[rt];
        sum[rt << 1] = lz[rt];
        sum[rt << 1 | 1] = lz[rt];
        lz[rt] = -INF;
    }
}

inline void build(int rt,int l,int r)
{
    sum[rt] = -INF;
    lz[rt] = -INF;
    if(l == r)
    {
        return ;
    }
    int mid = (l + r) >> 1;
    build(rt << 1,l,mid);
    build(rt << 1 | 1,mid + 1,r);
}

inline void update(int rt,int l,int r,int al,int ar,int k)
{
    if(l > ar || r < al)
        return ;
    if(l <= al && r >= ar)
    {
        sum[rt] = k;
        lz[rt] = k;
        return ;
    }
    pushdown(rt);
    int mid = (al + ar) >> 1;
    update(rt << 1,l,r,al,mid,k);
    update(rt << 1 | 1,l,r,mid + 1,ar,k);
    sum[rt] = max(sum[rt << 1],sum[rt << 1 | 1]);
}

inline int query(int rt,int l,int r,int al,int ar)
{
    if(l > ar || r < al)
        return -INF;
    if(l <= al && r >= ar)
        return sum[rt];
    pushdown(rt);
    int mid = (al + ar) >> 1;
    return max(query(rt << 1,l,r,al,mid),query(rt << 1 | 1,l,r,mid + 1,ar));
}

int main()
{
    n = read();
    q = read();
    for(int i = 1; i <= n; ++i)
        aa[i] = read(),++vis[aa[i]];
    build(1,1,n);
    for(int i = 1; i <= n; ++i)
        last2[aa[i]] = i;
    for(int i = n; i >= 1; --i)
        last1[aa[i]] = i;
    for(int i = 1; i <= 200000; ++i)
    {
        if(last1[i] && last1[i] < last2[i])
        {
            update(1,last1[i],last2[i] - 1,1,n,0);
            update(1,last1[i],last1[i],1,n,vis[i]);
        }
    }
    int cur = 0;
    int ans = 0;
    for(int i = 1; i <= n; ++i)
        if(query(1,i,i,1,n) == -INF)
        {
            if(i == cur + 1)
                continue;
            int tmp = query(1,cur + 1,i - 1,1,n);
            ans += i - cur - tmp;
            cur = i;
        }
    printf("%d",ans);
}


#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;

constexpr int N = 200009;
int n, q, p[N], min_i[N], a[N], cnt[N];
pair<int, int> cc[N];
int ans = 0;

int get(int v) { return p[v] == v ? v : p[v] = get(p[v]); }

void unite(int v, int u) {
    v = get(v);
    u = get(u);
    if(u == v) return;
    if(cc[v].fi < cc[u].fi) swap(v, u);

    ans -= cc[v].fi - cc[v].se;
    ans -= cc[u].fi - cc[u].se;
    cc[v].fi += cc[u].fi;
    cc[v].se = max(cc[v].se, cc[u].se);
    p[u] = v;

    ans += cc[v].fi - cc[v].se;
}

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    cin >> n >> q;
    for(int i = 1; i <= n; ++i) {
        cin >> a[i];
        if(!min_i[a[i]]) min_i[a[i]] = i;
        cnt[a[i]] += 1;
    }

    iota(p, p + N, 0);
    for(int x = 0; x < N; ++x) {
        cc[x] = {cnt[x], cnt[x]};
    }

    stack<int> st;
    for(int i = 1; i <= n; ++i) {
        if(min_i[a[i]] == i) {
            st.push(a[i]);
        } else {
            while(st.size() && min_i[st.top()] > min_i[a[i]]) {
                unite(st.top(), a[i]);
                st.pop();
            }
        }
    }
    cout << ans << '\n';
}


// This code is just for testing :)
#include <bits/stdc++.h>
#define fi first
#define se second
using ll = long long;
using namespace std;

// namespace solve1 {
//     constexpr int N = 200009;
//     int n;
//     vector<int> a;
//     int ans = 0;
//     vector<pair<int, int>> cc(N);
//     int par[N];
//     bool seen[N];
//     int cnt[N];
//     bool onstack[N];

//     int get(int i) {
//         return par[i] == i ? i : par[i] = get(par[i]);
//     }

//     void combine(int x, int y) {
//         x = get(x);
//         y = get(y);
//         if(x == y) return;
//         ans -= cc[x].fi - cc[x].se;
//         ans -= cc[y].fi - cc[y].se;
//         if(cc[x].fi < cc[y].fi) swap(x, y);
//         cc[x].fi += cc[y].fi;
//         cc[x].se = max(cc[x].se, cc[y].se);
//         par[y] = x;
//         ans += cc[x].fi - cc[x].se;
//     }

//     int solve(int _n, vector<int> _a) {
//         iota(par, par + N, 0);
//         n = _n;
//         for(int i = 0; i < n; ++i) {
//             int x;
//             x = _a[i];
//             a.push_back(x);
//             cnt[x] += 1;
//         }

//         for(int i = 1; i < N; ++i) {
//             cc[i].se = cc[i].fi = cnt[i];
//         }

//         stack<int> st;
//         for(int x : a) {
//             if(seen[x] && onstack[x]) {
//                 while(st.top() != x) {
//                     combine(st.top(), x);
//                     onstack[st.top()] = false;
//                     st.pop();
//                 }
//             } else {
//                 st.push(x);
//                 seen[x] = true;
//                 onstack[x] = true;
//             }
//         }

//         return ans;
//     }
// }

namespace solve2 {
    constexpr int N = 200009;
    int n;
    vector<int> a;
    int ans = 0;
    vector<pair<int, int>> cc(N);
    int par[N];
    bool seen[N];
    int cnt[N];

    int get(int i) {
        return par[i] == i ? i : par[i] = get(par[i]);
    }

    void combine(int x, int y) {
        x = get(x);
        y = get(y);
        if(x == y) return;
        ans -= cc[x].fi - cc[x].se;
        ans -= cc[y].fi - cc[y].se;
        if(cc[x].fi < cc[y].fi) swap(x, y);
        cc[x].fi += cc[y].fi;
        cc[x].se = max(cc[x].se, cc[y].se);
        par[y] = x;
        ans += cc[x].fi - cc[x].se;
    }

    int mnidx[N], mxidx[N];

    int solve(int _n, vector<int>& _a) {
        fill(mnidx, mnidx + N, -1);
        fill(mxidx, mxidx + N, -1);
        iota(par, par + N, 0);
        n = _n;
        for(int i = 0; i < n; ++i) {
            int x;
            x = _a[i];
            a.push_back(x);
            if(mnidx[x] == -1) mnidx[x] = i;
            mxidx[x] = i;
            cnt[x] += 1;
        }

        for(int i = 1; i < N; ++i) {
            cc[i].se = cc[i].fi = cnt[i];
        }

        for(int x : a) {
            for(int i = mnidx[x]; i < mxidx[x]; ++i) {
                combine(a[i], x);
            }
        }
        return ans;
    }
}

int32_t main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);

    int n, q;
    cin >> n >> q;
    vector<int> a(n);
    for(int i = 0; i < n; ++i) cin >> a[i];
    cout << solve2::solve(n, a) << endl;
    // mt19937 rng(time(0));
    // int T = 100;
    // while(T--) {
    //     cout << "Test case " << T << endl;
    //     int n = rng() % 20;
    //     vector<int> a(n);
    //     for(int i = 0; i < n; ++i) a[i] = rng() % n + 1;
    //     int s1 = solve1::solve(n, a);
    //     int s2 = solve2::solve(n, a);
    //     if(s1 != s2) {
    //         cout << "S1 is " << s1 << " and S2 is " << s2 << endl;
    //         cout << "Found : ";
    //         for(int x : a) cout << x << ' ';
    //         cout << endl;
    //         return 0;
    //     }
    // }

}


#include <bits/stdc++.h>
using namespace std;

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    int n, q;
    cin >> n >> q;

    constexpr int N = 200009;
    vector<int> a(N), last(N), cnt(N);
    for(int i = 0; i < n; ++i) {
        cin >> a[i];
        last[a[i]] = i;
        cnt[a[i]] += 1;
    }

    int ans = 0;
    for(int st = 0; st < n; ) {
        int ed = last[a[st]];
        int mx = cnt[a[st]];
        for(int i = st; i <= ed; ++i) {
            ed = max(ed, last[a[i]]);
            mx = max(mx, cnt[a[i]]);
        }
        ans += (ed - st + 1) - mx;
        st = ed + 1;
    }
    cout << ans << '\n';
}


#include <bits/stdc++.h>
#define fi first
#define se second
using ll = long long;
using namespace std;

constexpr int N = 200009;
int n;
vector<int> a;
int ans = 0;
vector<pair<int, int>> cc(N);
int par[N];
bool seen[N];
int cnt[N];

int get(int i) {
    return par[i] == i ? i : par[i] = get(par[i]);
}

void combine(int x, int y) {
    x = get(x);
    y = get(y);
    if(x == y) return;
    ans -= cc[x].fi - cc[x].se;
    ans -= cc[y].fi - cc[y].se;
    if(cc[x].fi < cc[y].fi) swap(x, y);
    cc[x].fi += cc[y].fi;
    cc[x].se = max(cc[x].se, cc[y].se);
    par[y] = x;
    ans += cc[x].fi - cc[x].se;
}

int32_t main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    iota(par, par + N, 0);
    int chert;
    cin >> n >> chert;
    for(int i = 0; i < n; ++i) {
        int x;
        cin >> x;
        a.push_back(x);
        cnt[x] += 1;
    }

    for(int i = 1; i < N; ++i) {
        cc[i].se = cc[i].fi = cnt[i];
    }

    stack<int> st;
    for(int x : a) {
        if(seen[x]) {
            while(st.size()) {
                combine(st.top(), x); st.pop();
            }
        } else {
            st.push(x);
            seen[x] = true;
        }
    }
    cout << ans << '\n';
}