# ifdef _MSVC_LANG

# define _SCL_SECURE_NO_WARNINGS
# pragma warning( disable : 0325 ) // inline namespace Error

# endif


# include <iostream>
# include <string>
# include <iomanip>
# include <cstdio>
# include <array>
# include <numeric>
# include <algorithm>
# include <vector>
# include <functional>
# include <fstream>
# include <random>
# include <bitset>
# include <map>
# include <unordered_set>
# include <set>


// C++ 11 前提

using Ull = unsigned long long;
using Ll = long long;

template<typename T>
using Vec = std::vector<T>;

template<typename T, size_t L>
using Ary = std::array<T, L>;

namespace
{

    namespace meta
    {
        namespace coming
        {
            // c++ 17;
            template<class... _Types>
            using void_t = void;

            template<class _Ty,
                _Ty _Val>
                struct integral_constant
            {	// convenient template for integral constant types
                static constexpr _Ty value = _Val;

                using value_type = _Ty;
                using type = integral_constant;

                constexpr operator value_type() const noexcept
                {	// return stored value
                    return (value);
                }

                constexpr value_type operator()() const noexcept
                {	// return stored value
                    return (value);
                }
            };

            // c++ 17;
            template<bool _Val>
            using bool_constant = integral_constant<bool, _Val>;


            // c++ 14
            template<bool _Test,
                class _Ty = void>
                using enable_if_t = typename std::enable_if<_Test, _Ty>::type;
        }

        namespace core
        {

            template < class, class = void > struct enable_std_begin_end : std::false_type {};
            template < typename T >
            struct enable_std_begin_end<T,
                coming::void_t<decltype(std::begin(std::declval<const T&>()), std::end(std::declval<const T&>()))>> : std::true_type {}; // c++ 17


            template < class, class = void > struct enable_adl_begin_end : std::false_type {};
            template < typename T >
            struct enable_adl_begin_end<T,
                coming::void_t<decltype(begin(std::declval<const T&>()), end(std::declval<const T&>()))>> : std::true_type {};
        }

        template < typename T >
        struct is_range
            : coming::bool_constant< core::enable_std_begin_end<T>::value || core::enable_adl_begin_end<T>::value>
        {
        };

        /// <summary>
        /// ある値が0以上か
        /// </summary>
        template<class T, T num, class = std::nullptr_t> struct is_positive
            : coming::bool_constant<(num >= 0)>
        {
        };

    }


    inline namespace extension
    {
        inline namespace container_io
        {
            inline namespace in
            {

                /// <summary>
                /// for cin with STL container
                /// </summary>
                template< template<class ...> class Container, class ... Args, typename = meta::coming::enable_if_t<!std::is_same<Container<Args ...>, std::string>::value> >
                std::istream& operator >> (std::istream& is, Container<Args ...>& container)
                {
                    for (auto& elem : container) is >> elem; return is;
                }

                /// <summary>
                /// for cin with std::arary
                /// </summary>
                template<class T, size_t L>
                std::istream& operator >> (std::istream& is, std::array<T, L>& container)
                {
                    for (auto& elem : container) is >> elem; return is;
                }

                /// <summary>
                /// for cin with raw array
                /// </summary>
                template<class T, size_t L>
                std::istream& operator >> (std::istream& is, T(&ary)[L])
                {
                    for (int i{}; i < L; ++i) is >> ary[i]; return is;
                }

            }

            inline namespace out
            {
                namespace settings
                {
                    /// <summary>
                    /// 要素間の区切り文字
                    /// </summary>
                    const auto sepOfContainerElements{"\n"};
                    /// <summary>
                    /// コンテナ間の区切り文字
                    /// </summary>
                    const auto sepOfContainer{"\n"};
                }


                /// <summary>
                /// for cout Container with STL container
                /// </summary>
                template < template<class ...> class Container, class ... Args, typename = meta::coming::enable_if_t<!std::is_same<Container<Args ...>, std::string> ::value> >
                std::ostream& operator << (std::ostream& os, const Container<Args ...>& container)
                {
                    for (const auto& elem : container) os << elem << settings::sepOfContainerElements; return os;
                }

                /// <summary>
                /// for cout Container with std::array
                /// </summary>
                template < class T, size_t L>
                std::ostream& operator << (std::ostream& os, const std::array<T, L> container)
                {
                    for (const auto& elem : container) os << elem << settings::sepOfContainerElements; return os;
                }

                /// <summary>
                /// for cout Container with raw array
                /// </summary>
                template < class T, size_t L, typename = meta::coming::enable_if_t<!std::is_same<T, char>::value> >
                std::ostream& operator << (std::ostream& os, const T(&ary)[L])
                {
                    for (const auto& elem : ary) os << elem << settings::sepOfContainerElements; return os;
                }



                /// <summary>
                /// for cout Container in Container with STL container
                /// </summary>
                template < template<class ...> class Container1, class ... Cont1Args,
                    template<class ...> class Container2, class ... Cont2Args  >
                std::ostream& operator << (std::ostream& os, const Container1< Container2<Cont2Args ...>, Cont1Args ...>& container)
                {
                    for (const auto& elem : container) os << elem << settings::sepOfContainer; return os;
                }



                /// <summary>
                /// for cout Container in Container with std::array
                /// </summary>
                template < template<class ...> class Container, class ... Args, size_t L >
                std::ostream& operator << (std::ostream& os, const std::array<Container<Args ...>, L>& container)
                {
                    for (const auto& elem : container) os << elem << settings::sepOfContainer; return os;
                }
                /// <summary>
                /// for cout Container in Container with std::array
                /// </summary>
                template < template<class ...> class Container, class ... Args, size_t L, class T  >
                std::ostream& operator << (std::ostream& os, const Container<std::array<T, L>, Args ...>& container)
                {
                    for (const auto& elem : container) os << elem << settings::sepOfContainer; return os;
                }
                /// <summary>
                /// for cout Container in Container with std::array
                /// </summary>
                template < class T, size_t L1, size_t L2 >
                std::ostream& operator << (std::ostream& os, const std::array<std::array<T, L2>, L1> container)
                {
                    for (const auto& elem : container) os << elem << settings::sepOfContainer; return os;
                }


                /// <summary>
                /// for cout raw ary in raw ary
                /// </summary>
                template < class T, size_t L1, size_t L2 >
                std::ostream& operator << (std::ostream& os, const T(&ary)[L1][L2])
                {
                    for (size_t i{}; i < L1; ++i) os << ary[i] << settings::sepOfContainer; return os;
                }

            }
        }


        template<typename T, size_t L, typename Function>
        void for_each(T(&ary)[L], Function lambda)
        {
            for (size_t i{}; i < L; ++i)
                lambda(static_cast<T&>(ary[i]));
        }


    }


    inline namespace util
    {

        template<typename T>
        void SetAll(T& container, typename T::value_type value = typename T::value_type{})
        {
            for (typename T::reference content : container) content = value;
        }

        template<typename T, size_t L>
        void SetAll(T(&ary)[L], T value)
        {
            for (size_t i{}; i < L; ++i) ary[i] = value;
        }

        template<typename T, typename U, size_t L1, size_t L2>
        void SetAll(T(&ary)[L1][L2], U value)
        {
            for (size_t i{}; i < L1; ++i) SetAll(ary[i], value);
        }


    }


    inline namespace alg
    {
        bool IsPrime(const Ull n)
        {
            switch (n)
            {
            case 0: case 1:
                return false;
            case 2:
                return true;
            default:

                if (n % 2 == 0) return false;

                for (Ull i{3}; i * i <= n; i += 2)
                {
                    if (n % i == 0) return false;
                }
            }

            return true;
        }

        // 最大公約数
        Ull EuclideanAlg(Ull n1, Ull n2)
        {
            //if (n1 < 0 || n2 < 0) return 0;
            if (n2 > n1) std::swap(n1, n2);

            Ull r;
            while ((r = n1 % n2) != 0)
            {
                n1 = n2;
                n2 = r;
            }

            return n2;
        }

        // 最小公倍数
        Ull LCM(const std::vector<Ull>& values)
        {
            if (values.size() == 0)
                return 0;
            if (values.size() == 1)
                return values[0];
            if (values.size() == 2)
                return values[0] * values[1] / EuclideanAlg(values[0], values[1]);

            auto mid = values.cbegin() + values.size() / 2;

            return LCM(std::vector<Ull>{LCM(std::vector<Ull>(values.begin(), mid)), LCM(std::vector<Ull>(mid, values.end()))});
        }
    }


    void Solve();

}

# if true
int main()
{
    Solve();
    return 0;
}
# endif

template<typename T>
void print(T& data, std::string sep = " ")
{
    for (auto& val : data)
    {
        std::cout << (int)val << sep;
    }
    std::cout << std::endl;
}

namespace
{
    constexpr size_t maxYear{7368791};
    constexpr size_t arySize{maxYear + 1};
    char ary[arySize] = {0};

    void Solve()
    {
        while (true)
        {

            int m, n;
            std::cin >> m >> n;
            if (m == 0 && n == 0) break;


            for (int i{m}, nn{}; nn < n; ++i)
            {
                if (ary[i] == 1)
                    continue;

                for (int j{i}; j < arySize; j += i)
                    ary[j] = 1;

                ++nn;
            }

            //print(ary);

            bool hasAns = false;
            for (int i{m}; i < arySize; ++i)
            {
                if (ary[i] == 0 && !hasAns)
                {
                    std::cout << i << std::endl;
                    hasAns = true;
                }

                ary[i] = 0;
            }
        }
    }

}


Measured memory_bytes: 10220