'use strict';

function main(input) {
  const lines = input.split('\n');
  const n = lines[0].split(' ').shift() | 0;
  const d = lines[1].split(' ').map((x) => x | 0);

  let ans = n;
  const reg = RegExp(d.join('|'));
  while (reg.test(ans)) {
    ans += 1;
  }
  console.log(ans);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));
