stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;



int main() {

    int n, k;

    cin >> n >> k;

    vector<int> d(k);

    for(int i=0; i<k; i++){

        cin >> d[i];

    }

    int ans = n;

    while(1){

        bool flag = true;

        for(int i=0; i<to_string(ans).size(); i++){

            for(int j=0; j<k; j++){

                if(to_string(ans)[i] - '0'== d[j]){

                    flag = false;

                    break;

                }

            }

            if(flag == false){

                break;

            }

        }

        if(flag){

            break;

        }else{

            ans++;

        }

    }

    cout << ans << endl;

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.1359955967988518x):
#include <bits/stdc++.h>

#define rep(i, n) for(int i=0; i<(n); ++i)

#define chmin(x,y) x = min(x,y)

#define chmax(x,y) x = max(x,y)

using namespace std;

using Graph = vector<vector<int>>;

typedef long long ll;

typedef pair<int, int> P;

const int inf = INT_MAX;

const ll INF = 1LL << 60;

const ll mod = 1e9+7;

const int dx[4] = {-1, 0, 1, 0};

const int dy[4] = {0, -1, 0, 1};



// 042C



int main(){

    int n, k;

    cin >> n >> k;

    vector<int> d(k);

    rep(i, k) cin >> d[i];

    int ans = n;

    bool flag = true;



    while(flag){

        string tmp = to_string(ans);

        int nn = tmp.size();

        flag = false;

        rep(i, nn){

            rep(j, d.size()){

                if(tmp[i]-'0' == d[j]){

                    flag = true;

                    break;

                }

            }

            if(flag) break;

        }

        if(!flag) break;

        ans++;

    }

    cout << ans << endl;

    return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;



int main() {

    int n, k;

    cin >> n >> k;

    int dis[256] {};

    for (int i = 0; i < k; i++) {

        char d;

        cin >> d;

        dis[d] = 1;

    }

    for (int i = n; i < 1000000; i++) {

        string s = to_string(i);

        int ok = 1;

        for (char c : s) {

            if (dis[c]) {

                ok = 0;

                break;

            }

        }

        if (ok) {

            cout << s << endl;

            break;

        }

    }

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.1353429276705436x):
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;



int main() {

    int n,k;

    cin>>n>>k;

    int no[10]{};

    for (int i=0;i<k;i++) {

        int a;cin>>a;

        no[a]=1;

    }

    for (int i=n;;i++) {

        int t=i;

        int f=1;

        while (t) {

            if (no[t%10])

                f=0;

            t/=10;

        }

        if (f) {

            cout<<i<<endl;

            break;

        }

    }

    return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>



using namespace std;

template <class T> string toStr(T par) {

	ostringstream oss;

	oss<<par;

	return oss.str();

}

string s;

int n, k, q, dislikes[11];

int main()

{

    cin >> n >> k;

    for(int i = 0; i < k ; i++)

    {

        cin >> q;

        dislikes[q] = 1;

    }



    while(true)

    {

        int prev_n = n, cnt = 0;

        bool ok = false;

        s = toStr(n);

        for(int i = s.size() - 1; i >= 0; i--)

        {

            if(dislikes[s[i] - '0'])

                ok = true;

        }

        if(ok) n++;

        else break;

    }

    cout << n << endl;

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 8.27838948653901x):
#include<cstdio>

#include<algorithm>

using namespace std;

int a,vis[66],n,k;

bool check(int x)

{

	while(x)

	{

		if(vis[x%10]) return 0;

		x/=10;

	}

	return 1;

}

int main()

{

	scanf("%d%d",&n,&k);

	for(int i=1;i<=k;i++)

	{

		scanf("%d",&a);

		vis[a]=1;

	}

	for(int i=n;;i++)

	{

		if(check(i))

		{

			printf("%d",i);

			break;

		}

	}

}
// Slower C++ solution:
#include<bits/stdc++.h>



using namespace std;

template <class T> string toStr(T par) {

	ostringstream oss;

	oss<<par;

	return oss.str();

}

string s;

int n, k, q, dislikes[11];

int main()

{

    cin >> n >> k;

    for(int i = 0; i < k ; i++)

    {

        cin >> q;

        dislikes[q] = 1;

    }



    while(true)

    {

        int prev_n = n, cnt = 0;

        bool ok = false;

        s = toStr(n);

        for(int i = s.size() - 1; i >= 0; i--)

        {

            if(dislikes[s[i] - '0'])

                ok = true;

        }

        if(ok) n++;

        else break;

    }

    cout << n << endl;

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 1.617187437078609x):
#include<iostream>

#include<algorithm>

using namespace std;

bool num[10];

int a,b,c,l,n,k;

int main()

{

	cin>>n>>k;

	int cnt=0;

	for(int i=1;i<=k;i++)

    {

        int a;

        cin>>a;

        num[a]=true;

    }

    int i=n;

    for(;;i++)

    {

        int t=i;

        int flog=1;

        for(;t;t/=10)

        {

            if(num[t%10])

            {

                flog=0;

                break;

            }

        }

        if(flog)

            break;

    }

    cout<<i<<endl;

	return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>



using namespace std;

template <class T> string toStr(T par) {

	ostringstream oss;

	oss<<par;

	return oss.str();

}

string s;

int n, k, q, dislikes[11];

int main()

{

    cin >> n >> k;

    for(int i = 0; i < k ; i++)

    {

        cin >> q;

        dislikes[q] = 1;

    }



    while(true)

    {

        int prev_n = n, cnt = 0;

        bool ok = false;

        s = toStr(n);

        for(int i = s.size() - 1; i >= 0; i--)

        {

            if(dislikes[s[i] - '0'])

                ok = true;

        }

        if(ok) n++;

        else break;

    }

    cout << n << endl;

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 1.6075103819319738x):
#include<bits/stdc++.h>



using namespace std;



int main()

{

	int N,k;

	cin>>N>>k;

	int d[10];

	for(int i=0;i<k;i++)

		cin>>d[i];

	int n=N;

	int flag;

	int h=N;

	while(1)

	{

		flag=1;

		while(n)

		{

			int r=n%10;

			for(int i=0;i<k;i++)

			{

				if(d[i]==r)

				{

					flag=0;

					break;

				}

			}

			n=n/10;

			if(flag==0)

			{

				break;

			}

		}

		if(flag==1)

		{

			cout<<h<<endl;

			break;

		}

		else{

			h++;

			n=h;

		}

	}

return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>



using namespace std;

template <class T> string toStr(T par) {

	ostringstream oss;

	oss<<par;

	return oss.str();

}

string s;

int n, k, q, dislikes[11];

int main()

{

    cin >> n >> k;

    for(int i = 0; i < k ; i++)

    {

        cin >> q;

        dislikes[q] = 1;

    }



    while(true)

    {

        int prev_n = n, cnt = 0;

        bool ok = false;

        s = toStr(n);

        for(int i = s.size() - 1; i >= 0; i--)

        {

            if(dislikes[s[i] - '0'])

                ok = true;

        }

        if(ok) n++;

        else break;

    }

    cout << n << endl;

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 1.617496945862178x):
#include <iostream>

using namespace std;

int sign[10]={0};

int main()

{

	int N,K,t=0,a,flag;

	cin>>N>>K;

	for(int i=0;i<K;i++)

	{

		cin>>a;

		sign[a]=1;

	}

	for(int i=N;i<100000;i++)

	{

		int j=i;

		flag=1;

		while(j)

		{

			if(sign[j%10]==1)

			{

				flag=0;

				break;

			}	

			j=j/10;

		}

		if(flag==1)

		{

			cout<<i<<endl;

			break;

		}

	}

	return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>



using namespace std;

template <class T> string toStr(T par) {

	ostringstream oss;

	oss<<par;

	return oss.str();

}

string s;

int n, k, q, dislikes[11];

int main()

{

    cin >> n >> k;

    for(int i = 0; i < k ; i++)

    {

        cin >> q;

        dislikes[q] = 1;

    }



    while(true)

    {

        int prev_n = n, cnt = 0;

        bool ok = false;

        s = toStr(n);

        for(int i = s.size() - 1; i >= 0; i--)

        {

            if(dislikes[s[i] - '0'])

                ok = true;

        }

        if(ok) n++;

        else break;

    }

    cout << n << endl;

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 1.616548130878612x):
#include<cstdio>

#include<cstring>

#include<iostream>

#include<algorithm>

#define ll long long

#define Di 3.1415926

#include<math.h>

#include<string>

#include<set>

#define INF 0x3f3f3f3f

using namespace std;

ll  gcd(ll a,ll b)

{

    return a%b? gcd(b,a%b):b;

}

int a[200];

int s[100];

 bool judge(int i)

 {

     while(i)

     {

         int t=i%10;

            if(s[t])

            {

                return false;

            }

            i/=10;

     }

     return true;

 }

int main()

{

     int m,i;

     int n;

     cin>>m>>n;

     for(i=0;i<n;i++)

     {

         cin>>a[i];

          s[a[i]]=1;



     }

     for(i=m;;i++)

     {

          if(judge(i))

          {

            cout<<i<<endl;

              break;

          }

     }





 return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>



using namespace std;

template <class T> string toStr(T par) {

	ostringstream oss;

	oss<<par;

	return oss.str();

}

string s;

int n, k, q, dislikes[11];

int main()

{

    cin >> n >> k;

    for(int i = 0; i < k ; i++)

    {

        cin >> q;

        dislikes[q] = 1;

    }



    while(true)

    {

        int prev_n = n, cnt = 0;

        bool ok = false;

        s = toStr(n);

        for(int i = s.size() - 1; i >= 0; i--)

        {

            if(dislikes[s[i] - '0'])

                ok = true;

        }

        if(ok) n++;

        else break;

    }

    cout << n << endl;

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 1.6159304059026665x):
#include<stdio.h>

#include<iostream>

#include<string>

#include<algorithm>

using namespace std;

int main()

{

    int n,m;

    while(cin>>n>>m)

    {

        int k;

        int vis[12]={0};

        for(int i=0;i<m;i++ )

        {

            cin>>k;

            vis[k]=1;

        }

        while(1)

        {

            int flag=1;

            k=n;

            while(k)

            {

                int t =k%10;

                if(vis[t])

                {

                    flag=0;

                    break;

                }

                k/=10;

            }

            if(flag)

            {

                cout<<n<<endl;

                break;

            }

            n++;

        }

    }

    return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>



using namespace std;

template <class T> string toStr(T par) {

	ostringstream oss;

	oss<<par;

	return oss.str();

}

string s;

int n, k, q, dislikes[11];

int main()

{

    cin >> n >> k;

    for(int i = 0; i < k ; i++)

    {

        cin >> q;

        dislikes[q] = 1;

    }



    while(true)

    {

        int prev_n = n, cnt = 0;

        bool ok = false;

        s = toStr(n);

        for(int i = s.size() - 1; i >= 0; i--)

        {

            if(dislikes[s[i] - '0'])

                ok = true;

        }

        if(ok) n++;

        else break;

    }

    cout << n << endl;

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 1.6310905983729553x):
#include<cstdio>

#include<algorithm>

#include<iostream>

#include<cstring>

using namespace std;

int n,k,c,t;

int a[10];

bool y(int x)

{

    for(;x;x/=10)

    if(a[x%10])

        return false;

    return true;

}

int main()

{

    scanf("%d %d",&n,&k);

    for(int i=0;i<k;i++)

      {

         scanf("%d",&t);

         a[t]=1;

      }

    while(!y(n))

    {

        n++;



    }

    cout<<n<<endl;

    return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>



using namespace std;

template <class T> string toStr(T par) {

	ostringstream oss;

	oss<<par;

	return oss.str();

}

string s;

int n, k, q, dislikes[11];

int main()

{

    cin >> n >> k;

    for(int i = 0; i < k ; i++)

    {

        cin >> q;

        dislikes[q] = 1;

    }



    while(true)

    {

        int prev_n = n, cnt = 0;

        bool ok = false;

        s = toStr(n);

        for(int i = s.size() - 1; i >= 0; i--)

        {

            if(dislikes[s[i] - '0'])

                ok = true;

        }

        if(ok) n++;

        else break;

    }

    cout << n << endl;

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 1.1600283122064217x):
#include<iostream>

#include<cstdio>

#include<cstring>

#include<cmath>

#include<algorithm>

using namespace std;

int num[100005];

bool judge(int n)

{

	while(n)

	{

		int b=n%10;

		if(num[b])

		{

		  	return false;

		}

	   n/=10;	  

	}

	return true;

}

int main()

{

	int N,K;

	while(scanf("%d%d",&N,&K)!=EOF)

	{

		memset(num,0,sizeof(num));

		int k;

		for(int i=0;i<K;i++)

		{

			scanf("%d",&k);

			  num[k]=1;

		}

		for(int i=N;;i++)

		{

			if(judge(i))

			{

				printf("%d\n",i);

				break;

			}

		}

	}

	return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>



using namespace std;

template <class T> string toStr(T par) {

	ostringstream oss;

	oss<<par;

	return oss.str();

}

string s;

int n, k, q, dislikes[11];

int main()

{

    cin >> n >> k;

    for(int i = 0; i < k ; i++)

    {

        cin >> q;

        dislikes[q] = 1;

    }



    while(true)

    {

        int prev_n = n, cnt = 0;

        bool ok = false;

        s = toStr(n);

        for(int i = s.size() - 1; i >= 0; i--)

        {

            if(dislikes[s[i] - '0'])

                ok = true;

        }

        if(ok) n++;

        else break;

    }

    cout << n << endl;

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 4.781978572824639x):
#include<cstdio>

#include<cstring>

#include<algorithm>

using namespace std;

bool flag[10];

bool check(int x){

	char s[100];

	sprintf(s,"%d",x);

	for(int i=0;s[i];i++)

		if(flag[s[i]-'0'])

			return false;

	return true;

}

int main(){

	int n,m;

	while(~scanf("%d%d",&n,&m)){

		int temp;

		for(int i=0;i<m;i++){

			scanf("%d",&temp);

			flag[temp]=1;

		}

		int ans;

		for(int i=n;;i++)

			if(check(i)){

				ans=i;

				break;

			}

			printf("%d\n",ans);

	}

}
// Slower C++ solution:
#include<iostream>

#include<algorithm>

using namespace std;

bool num[10];

int a,b,c,l,n,k;

int main()

{

	cin>>n>>k;

	int cnt=0;

	for(int i=1;i<=k;i++)

    {

        int a;

        cin>>a;

        num[a]=true;

    }

    int i=n;

    for(;;i++)

    {

        int t=i;

        int flog=1;

        for(;t;t/=10)

        {

            if(num[t%10])

            {

                flog=0;

                break;

            }

        }

        if(flog)

            break;

    }

    cout<<i<<endl;

	return 0;

}


// Faster C++ solution for the same problem (measured speedup: 2.956972372641672x):
#include<cstdio>

#include<cstring>

#include<algorithm>

using namespace std;

bool flag[10];

bool check(int x){

	char s[100];

	sprintf(s,"%d",x);

	for(int i=0;s[i];i++)

		if(flag[s[i]-'0'])

			return false;

	return true;

}

int main(){

	int n,m;

	while(~scanf("%d%d",&n,&m)){

		int temp;

		for(int i=0;i<m;i++){

			scanf("%d",&temp);

			flag[temp]=1;

		}

		int ans;

		for(int i=n;;i++)

			if(check(i)){

				ans=i;

				break;

			}

			printf("%d\n",ans);

	}

}
// Slower C++ solution:
#include<bits/stdc++.h>



using namespace std;



int main()

{

	int N,k;

	cin>>N>>k;

	int d[10];

	for(int i=0;i<k;i++)

		cin>>d[i];

	int n=N;

	int flag;

	int h=N;

	while(1)

	{

		flag=1;

		while(n)

		{

			int r=n%10;

			for(int i=0;i<k;i++)

			{

				if(d[i]==r)

				{

					flag=0;

					break;

				}

			}

			n=n/10;

			if(flag==0)

			{

				break;

			}

		}

		if(flag==1)

		{

			cout<<h<<endl;

			break;

		}

		else{

			h++;

			n=h;

		}

	}

return 0;

}


// Faster C++ solution for the same problem (measured speedup: 2.9747730568790827x):
#include<cstdio>

#include<cstring>

#include<algorithm>

using namespace std;

bool flag[10];

bool check(int x){

	char s[100];

	sprintf(s,"%d",x);

	for(int i=0;s[i];i++)

		if(flag[s[i]-'0'])

			return false;

	return true;

}

int main(){

	int n,m;

	while(~scanf("%d%d",&n,&m)){

		int temp;

		for(int i=0;i<m;i++){

			scanf("%d",&temp);

			flag[temp]=1;

		}

		int ans;

		for(int i=n;;i++)

			if(check(i)){

				ans=i;

				break;

			}

			printf("%d\n",ans);

	}

}
// Slower C++ solution:
#include <iostream>

using namespace std;

int sign[10]={0};

int main()

{

	int N,K,t=0,a,flag;

	cin>>N>>K;

	for(int i=0;i<K;i++)

	{

		cin>>a;

		sign[a]=1;

	}

	for(int i=N;i<100000;i++)

	{

		int j=i;

		flag=1;

		while(j)

		{

			if(sign[j%10]==1)

			{

				flag=0;

				break;

			}	

			j=j/10;

		}

		if(flag==1)

		{

			cout<<i<<endl;

			break;

		}

	}

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 2.9564065546199165x):
#include<cstdio>

#include<cstring>

#include<algorithm>

using namespace std;

bool flag[10];

bool check(int x){

	char s[100];

	sprintf(s,"%d",x);

	for(int i=0;s[i];i++)

		if(flag[s[i]-'0'])

			return false;

	return true;

}

int main(){

	int n,m;

	while(~scanf("%d%d",&n,&m)){

		int temp;

		for(int i=0;i<m;i++){

			scanf("%d",&temp);

			flag[temp]=1;

		}

		int ans;

		for(int i=n;;i++)

			if(check(i)){

				ans=i;

				break;

			}

			printf("%d\n",ans);

	}

}
// Slower C++ solution:
#include<cstdio>

#include<cstring>

#include<iostream>

#include<algorithm>

#define ll long long

#define Di 3.1415926

#include<math.h>

#include<string>

#include<set>

#define INF 0x3f3f3f3f

using namespace std;

ll  gcd(ll a,ll b)

{

    return a%b? gcd(b,a%b):b;

}

int a[200];

int s[100];

 bool judge(int i)

 {

     while(i)

     {

         int t=i%10;

            if(s[t])

            {

                return false;

            }

            i/=10;

     }

     return true;

 }

int main()

{

     int m,i;

     int n;

     cin>>m>>n;

     for(i=0;i<n;i++)

     {

         cin>>a[i];

          s[a[i]]=1;



     }

     for(i=m;;i++)

     {

          if(judge(i))

          {

            cout<<i<<endl;

              break;

          }

     }





 return 0;

}


// Faster C++ solution for the same problem (measured speedup: 2.9581417846343863x):
#include<cstdio>

#include<cstring>

#include<algorithm>

using namespace std;

bool flag[10];

bool check(int x){

	char s[100];

	sprintf(s,"%d",x);

	for(int i=0;s[i];i++)

		if(flag[s[i]-'0'])

			return false;

	return true;

}

int main(){

	int n,m;

	while(~scanf("%d%d",&n,&m)){

		int temp;

		for(int i=0;i<m;i++){

			scanf("%d",&temp);

			flag[temp]=1;

		}

		int ans;

		for(int i=n;;i++)

			if(check(i)){

				ans=i;

				break;

			}

			printf("%d\n",ans);

	}

}
// Slower C++ solution:
#include<stdio.h>

#include<iostream>

#include<string>

#include<algorithm>

using namespace std;

int main()

{

    int n,m;

    while(cin>>n>>m)

    {

        int k;

        int vis[12]={0};

        for(int i=0;i<m;i++ )

        {

            cin>>k;

            vis[k]=1;

        }

        while(1)

        {

            int flag=1;

            k=n;

            while(k)

            {

                int t =k%10;

                if(vis[t])

                {

                    flag=0;

                    break;

                }

                k/=10;

            }

            if(flag)

            {

                cout<<n<<endl;

                break;

            }

            n++;

        }

    }

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 2.9592725994616105x):
#include<cstdio>

#include<cstring>

#include<algorithm>

using namespace std;

bool flag[10];

bool check(int x){

	char s[100];

	sprintf(s,"%d",x);

	for(int i=0;s[i];i++)

		if(flag[s[i]-'0'])

			return false;

	return true;

}

int main(){

	int n,m;

	while(~scanf("%d%d",&n,&m)){

		int temp;

		for(int i=0;i<m;i++){

			scanf("%d",&temp);

			flag[temp]=1;

		}

		int ans;

		for(int i=n;;i++)

			if(check(i)){

				ans=i;

				break;

			}

			printf("%d\n",ans);

	}

}
// Slower C++ solution:
#include<cstdio>

#include<algorithm>

#include<iostream>

#include<cstring>

using namespace std;

int n,k,c,t;

int a[10];

bool y(int x)

{

    for(;x;x/=10)

    if(a[x%10])

        return false;

    return true;

}

int main()

{

    scanf("%d %d",&n,&k);

    for(int i=0;i<k;i++)

      {

         scanf("%d",&t);

         a[t]=1;

      }

    while(!y(n))

    {

        n++;



    }

    cout<<n<<endl;

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 2.931767602360504x):
#include<cstdio>

#include<cstring>

#include<algorithm>

using namespace std;

bool flag[10];

bool check(int x){

	char s[100];

	sprintf(s,"%d",x);

	for(int i=0;s[i];i++)

		if(flag[s[i]-'0'])

			return false;

	return true;

}

int main(){

	int n,m;

	while(~scanf("%d%d",&n,&m)){

		int temp;

		for(int i=0;i<m;i++){

			scanf("%d",&temp);

			flag[temp]=1;

		}

		int ans;

		for(int i=n;;i++)

			if(check(i)){

				ans=i;

				break;

			}

			printf("%d\n",ans);

	}

}
// Slower C++ solution:
#include<iostream>

#include<cstdio>

#include<cstring>

#include<cmath>

#include<algorithm>

using namespace std;

int num[100005];

bool judge(int n)

{

	while(n)

	{

		int b=n%10;

		if(num[b])

		{

		  	return false;

		}

	   n/=10;	  

	}

	return true;

}

int main()

{

	int N,K;

	while(scanf("%d%d",&N,&K)!=EOF)

	{

		memset(num,0,sizeof(num));

		int k;

		for(int i=0;i<K;i++)

		{

			scanf("%d",&k);

			  num[k]=1;

		}

		for(int i=N;;i++)

		{

			if(judge(i))

			{

				printf("%d\n",i);

				break;

			}

		}

	}

	return 0;

}


// Faster C++ solution for the same problem (measured speedup: 4.12229470824649x):
#include<cstdio>

#include<cstring>

#include<algorithm>

using namespace std;

bool flag[10];

bool check(int x){

	char s[100];

	sprintf(s,"%d",x);

	for(int i=0;s[i];i++)

		if(flag[s[i]-'0'])

			return false;

	return true;

}

int main(){

	int n,m;

	while(~scanf("%d%d",&n,&m)){

		int temp;

		for(int i=0;i<m;i++){

			scanf("%d",&temp);

			flag[temp]=1;

		}

		int ans;

		for(int i=n;;i++)

			if(check(i)){

				ans=i;

				break;

			}

			printf("%d\n",ans);

	}

}