#include <iostream>
#include <fstream>
using namespace std;
ifstream f("nrsufix.in");
ofstream g("nrsufix.out");
int x, nr, num, z=1, aux, gasit=0;
int main()
{
f >> x;
aux=x;
while (aux)
{
z*=10; aux/=10;
}
while (f >> num)
{
if (num%z==x) { nr=num; gasit=1; }
}
if (!gasit) g << "nu exista";
else g << nr;
}