#include <algorithm>
#include <iostream>
#include <string>
#include <stdexcept>

class N62
{
public:
    explicit N62(const std::string& digits) : N62(digits.c_str(), digits.size()) {}
    N62(const char* digits, std::size_t len) : value(0u)
    {
        for (std::size_t i = 0; i != len; ++i) {
            auto pos = std::find(std::begin(base), std::end(base), digits[i]);
            if (pos == std::end(base)) {
                throw std::runtime_error("bad format");
            }
            value *= base_size;
            value += pos - std::begin(base);
        }
    }
    N62(std::size_t value) : value(value) {}
    operator std::size_t () const { return value; }
    std::string str() const
    {
        if (value == 0u) {
            return "0";
        }
        std::string res;
        for (std::size_t n = value; n != 0; n /= base_size) {
            res.push_back(base[n % base_size]);
        }
        std::reverse(res.begin(), res.end());
        return res;
    }

private:
    std::size_t value;
private:
    static constexpr char base[] =
        "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
    static constexpr std::size_t base_size = 62;
};

std::ostream& operator << (std::ostream& os, const N62& n)
{
    return os << n.str() << "(" << std::size_t(n) << ")";
}

constexpr char N62::base[];

N62 operator "" _n62 (const char *t, std::size_t len)
{
    return N62(t, len);
}

int main()
{
    N62 a = "42"_n62;
    N62 b = 42;

    std::cout << a << "*" << b << " = " << N62(a * b) << std::endl;

    return 0;
}
