#include <bits/stdc++.h>

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// #pragma GCC optimize("Ofast")

using namespace std;
using ll = long long;

// MACRO
// for loop
#define REP(i, n) for (ll i = 0; i < ll(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define REPS(i, n, s) for (ll i = 0; i < ll(n); i += s)
#define REPDS(i, n, s) for (ll i = n - 1; i >= 0; i -= s)
#define FOR(i, a, b) for (ll i = a; i < ll(b); i++)
#define FORD(i, a, b) for (ll i = a; i > ll(b); i--)
#define FORS(i, a, b, s) for (ll i = a; i < ll(b); i += s)
#define FORDS(i, a, b, s) for (ll i = a; i > ll(b); i -= s)

// for vector
#define ALL(v) v.begin(), v.end()
#define SIZE(v) ll(v.size())
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<int>())
#define RSORTS(v) sort(ALL(v), greater<string>())
#define REVERSE(v) reverse(ALL(v))
#define FIND(v, n) (find(ALL(v), n) != v.end())
#define VFOR(e, v) for (auto &e : v)
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

// for set
#define SFOR(itr, st) for (auto itr = st.begin(); itr != st.end(); itr++)
#define SFORD(itr, st) for (auto itr = st.rbegin(); itr != st.rend(); itr++)
#define SFIND(st, keyword) (st.find(keyword) != st.end())

// alias
#define EB emplace_back // push as last element
#define PP pop_back     // pop last element
#define MP make_pair    // pair constractor
#define F first         // first element of pair
#define S second        // second element of pair

// Constant
const ll INF = 1000000000000; // 10^12:  ∞
const int MOD = 1000000007;   // 10^9+7: Congruence ceremony MOD
const int MAXR = 100000;      // 10^5:   Array Max Range
const char EL = '\n';         // newline

// Bits
const unsigned int BIT_FLAG_0 = (1 << 0); // 0000 0000 0000 0001
const unsigned int BIT_FLAG_1 = (1 << 1); // 0000 0000 0000 0010
const unsigned int BIT_FLAG_2 = (1 << 2); // 0000 0000 0000 0100
const unsigned int BIT_FLAG_3 = (1 << 3); // 0000 0000 0000 1000
const unsigned int BIT_FLAG_4 = (1 << 4); // 0000 0000 0001 0000
const unsigned int BIT_FLAG_5 = (1 << 5); // 0000 0000 0010 0000
const unsigned int BIT_FLAG_6 = (1 << 6); // 0000 0000 0100 0000
const unsigned int BIT_FLAG_7 = (1 << 7); // 0000 0000 1000 0000

// Set
set<int> NUMBERS{0, 1, 2, 3, 4, 5, 6, 7, 8, 9};

// change max/min
template <class T>
bool chmax(T &a, const T &b)
{
  if (a < b)
  {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
  if (b < a)
  {
    a = b;
    return 1;
  }
  return 0;
}
// map
template <class Container, class Transform>
Container map(const Container &c, Transform f)
{
  Container r;
  r.reserve(c.size());
  std::transform(begin(c), end(c), std::back_inserter(r), f);
  return r;
}

// optimize in/out
#define OPTIMIZE_CIN_COUT() \
  cin.tie(0);               \
  ios::sync_with_stdio(false);

template <typename... Args>
void input(Args... args)
{
  for (int &e : {args...})
  {
    cin >> e;
  }
}
#define INPUT1(a) \
  int a = 0;      \
  cin >> a;
#define INPUT2(a, b) \
  int a = 0;         \
  int b = 0;         \
  cin >> a >> b;
#define INPUT3(a, b, c) \
  int a = 0;            \
  int b = 0;            \
  int c = 0;            \
  cin >> a >> b >> c;
#define INPUT4(a, b, c, d) \
  int a = 0;               \
  int b = 0;               \
  int c = 0;               \
  int d = 0;               \
  cin >> a >> b >> c >> d;
#define INPUTS(s) \
  string s = "";  \
  cin >> s;
#define INPUTS_BIT(n, b) \
  string _s = "";        \
  cin >> _s;             \
  bitset<n> b(_s);

#define INPUTA(n, a) \
  int n = 0;         \
  cin >> n;          \
  vector<int> a(n);  \
  REP(i, n)          \
  {                  \
    cin >> a[i];     \
  }
#define INPUTA2(n, l, a) \
  int n = 0, l = 0;      \
  cin >> n >> l;         \
  vector<int> a(l);      \
  REP(i, l)              \
  {                      \
    cin >> a[i];         \
  }
#define INPUTB(x, y, b)                     \
  int x = 0, y = 0;                         \
  cin >> x >> y;                            \
  vector<vector<int>> b(y, vector<int>(x)); \
  REP(i, y)                                 \
  {                                         \
    REP(j, x)                               \
    {                                       \
      cin >> b[i][j];                       \
    }                                       \
  }
#define INPUTG(y, g)                            \
  int __x__ = 3, y = 0;                         \
  cin >> y;                                     \
  vector<vector<int>> g(y, vector<int>(__x__)); \
  REP(i, y)                                     \
  {                                             \
    REP(j, __x__)                               \
    {                                           \
      cin >> g[i][j];                           \
    }                                           \
  }

// for string
int ctoi(char c)
{
  if (c >= '0' && c <= '9')
  {
    return c - '0';
  }
  return -1;
}
bool startWith(string target, string keyword)
{
  return equal(begin(keyword), end(keyword), begin(target));
}
string join(const vector<string> v, const char *delim = 0)
{
  string s;
  if (!v.empty())
  {
    s += v[0];
    for (decltype(v.size()) i = 1, c = v.size(); i < c; ++i)
    {
      if (delim)
        s += delim;
      s += v[i];
    }
  }
  return s;
}

int main()
{
  OPTIMIZE_CIN_COUT();

  // INPUT1(N);
  // INPUT2(A, B);
  // INPUT3(A, B, C);
  // INPUT4(A, B, C, D);
  // INPUTS(S);
  // INPUTS_BIT(<<num>>, B);
  // INPUTA(N, A);
  INPUTA2(N, K, D);
  // INPUTB(X, Y, B);
  // INPUTG(N, G);

  VFOR(e, D)
  {
    NUMBERS.erase(e);
  }

  FOR(i, N, 10 * N)
  {
    string str = to_string(i);
    bool flg = true;

    REP(i, str.size())
    {
      if (!SFIND(NUMBERS, ctoi(str[i])))
      {
        flg = false;
        break;
      }
    }
    if (flg)
    {
      cout << str << EL;
      exit(0);
    }
  }
}


Measured memory_bytes: 3724