A Hackerrank number is a magic number that can be used to get sudo permissions on the site. We are going to generate a hackerrank number from two integers A & B. Each number has two parts to it - the left (L) & the right side (R).  

For eg: for the number 100101, 

L could be 100 & R could be 101 (or) 
L could be 1 and R could be 00101 and so on.. 

How to generate a hackerrank number?

Let x & y be integers such that,

(1 <= x <= A & 1 <= y <= B) 

Generate the left part of any hackerrank number (L) by multiplying x and y (i.e) x*y 

and the right part of any hackerrank number (R) by bitwise xor-ing x and y (i.e) x^y

Add leading zeros to R to make length(R) = length(B) + 1. Concatenate both L & R to form the hackerrank number.

Can you find the sum of all possible hackerrank numbers generated by this rule?

Input format

Each input contains 2 integers A and B separated by a space. 

Constraints

1 <= A <= 30 

1 <= B <= 10^{8}

Output format

Print the sum of all possible numbers that satisfy the above mentioned property. 

Sample Input

2 4

Sample Output

14502

The left value can be one of  {1 * 1, 1 * 2, 1 * 3, 1 * 4, 2 * 1, 2 * 2, 2 * 3, 2 * 4} 

which is {1,2,3,4,2,4,6,8} 

and the distinct values are {1, 2, 3, 4, 6, 8}

The right value can be one of {1^1,1^2,1^3,1^4,2^1,2^2,2^3,2^4} 

which is {0, 3, 2, 5, 3, 0, 1, 6} 
and the distinct values are {0, 1, 2, 3, 5, 6} 

All the possible value are

{
    100, 101, 102, 103, 105, 106,
    200, 201, 202, 203, 205, 206,
    300, 301, 302, 303, 305, 306,
    400, 401, 402, 403, 405, 406,
    600, 601, 602, 603, 605, 606,
    800, 801, 802, 803, 805, 806 
}

S = all the sum of the above = 14502.

Note: Any number can only be added once.

Difficulty: HARD
Tags: Number theory

Starter code:

Solutions:
import math

def lcm(a, b):
	return a * b // math.gcd(a, b)
[a, b] = list(map(int, input().strip().split(' ')))
curr = b
leftmult = 10
while curr > 0:
	curr //= 10
	leftmult *= 10
[a, b] = sorted([a, b])
if a == 1 and b == 1:
	print(0)
else:
	themax = a + b
	for dig in range(30, 0, -1):
		if (a >> dig) % 2 == 1 and (b >> dig) % 2 == 1:
			themax = ((a >> dig) + (b >> dig) << dig) - 1
			break
	pow2 = 1
	curr = a - 1
	while curr > 0:
		pow2 *= 2
		curr //= 2
	exclude = 0
	rightnum = themax + 1
	if b % pow2 == 0:
		exclude = b
		rightnum -= 1
	if a == 1 and b % 2 == 0:
		exclude += 1
		rightnum -= 1
	righttot = themax * (themax + 1) // 2
	righttot -= exclude
	repqueue = dict()
	repqueue[31, 1] = -1
	for i in range(1, a + 1):
		addrep = dict()
		for (low, thelcm) in repqueue.keys():
			if repqueue[low, thelcm] != 0:
				try:
					addrep[min(low, i), lcm(thelcm, i)] -= repqueue[low, thelcm]
				except:
					addrep[min(low, i), lcm(thelcm, i)] = -repqueue[low, thelcm]
		for (x, y) in addrep:
			try:
				repqueue[x, y] += addrep[x, y]
				if repqueue[x, y] == 0:
					repqueue.pop((x, y))
			except:
				repqueue[x, y] = addrep[x, y]
	repqueue.pop((31, 1))
	leftnum = 0
	lefttot = 0
	for (low, thelcm) in repqueue.keys():
		num = b * low // thelcm
		leftnum += num * repqueue[low, thelcm]
		lefttot += thelcm * (num * (num + 1) // 2) * repqueue[low, thelcm]
	print(lefttot * rightnum * leftmult + righttot * leftnum)


def gcd(x, y):
	while y != 0:
		(x, y) = (y, x % y)
	return x

def sumProdRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x * y)
	return (sum(all), len(all))

def sumXorRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x ^ y)
	return (sum(all), len(all))

def sumProdOneDivider(divider, limit):
	count = limit // divider
	return (divider * (count + 1) * count // 2, count)

def get(result, x, limit):
	items = result.items()[:]
	if x not in result:
		result[x] = 0
	result[x] += 1
	if result[x] == 0:
		del result[x]
	for (d, v) in items:
		dx = d * x
		if dx > limit:
			continue
		if dx not in result:
			result[dx] = 0
		result[dx] -= v
		if result[dx] == 0:
			del result[dx]
	return result

def getInterval(start, finish, limit):
	result = {}
	for x in range(start, finish):
		items = list(result.items())[:]
		isdiv = False
		for d in range(start, x):
			if x % d == 0:
				isdiv = True
				break
		if isdiv:
			continue
		result[x] = 1
		for (d, v) in items:
			dx = d * x // gcd(d, x)
			if dx > limit:
				continue
			if dx not in result:
				result[dx] = 0
			result[dx] -= v
			if result[dx] == 0:
				del result[dx]
	return result

def sumProd(A, B):
	all = set()
	s = 0
	l = 0
	for x in range(A, 0, -1):
		process = getInterval(x, A + 1, A * B)
		for (d, v) in process.items():
			(sx0, lx0) = sumProdOneDivider(d, B * (x - 1))
			(sx1, lx1) = sumProdOneDivider(d, B * x)
			s += v * (sx1 - sx0)
			l += v * (lx1 - lx0)
	return (s, l)

def sumXor(A, B):
	if B < 100:
		return sumXorRef(A, B)
	b = B - 100
	s = b * (b + 1) // 2
	l = b + 1
	all = set()
	for x in range(1, A + 1):
		for y in range(b + 1, B + 1):
			xy = x ^ y
			if xy <= b:
				continue
			all.add(xy)
	s += sum(all)
	l += len(all)
	return (s, l)
(A, B) = map(int, input().split())
(prod, nprod) = sumProd(A, B)
(xor, nxor) = sumXor(A, B)
result = prod * nxor * pow(10, len('%d' % B) + 1) + nprod * xor
print(result)


def gcd(x, y):
	while y != 0:
		(x, y) = (y, x % y)
	return x

def sumProdRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x * y)
	return (sum(all), len(all))

def sumXorRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x ^ y)
	return (sum(all), len(all))

def sumProdOneDivider(divider, limit):
	count = limit // divider
	return (divider * (count + 1) * count // 2, count)

def get(result, x, limit):
	items = result.items()[:]
	if x not in result:
		result[x] = 0
	result[x] += 1
	if result[x] == 0:
		del result[x]
	for (d, v) in items:
		dx = d * x
		if dx > limit:
			continue
		if dx not in result:
			result[dx] = 0
		result[dx] -= v
		if result[dx] == 0:
			del result[dx]
	return result

def getInterval(start, finish, limit):
	result = {}
	for x in range(start, finish):
		items = list(result.items())[:]
		isdiv = False
		for d in range(start, x):
			if x % d == 0:
				isdiv = True
				break
		if isdiv:
			continue
		result[x] = 1
		for (d, v) in items:
			dx = d * x // gcd(d, x)
			if dx > limit:
				continue
			if dx not in result:
				result[dx] = 0
			result[dx] -= v
			if result[dx] == 0:
				del result[dx]
	return result

def sumProd(A, B):
	all = set()
	s = 0
	l = 0
	for x in range(A, 0, -1):
		process = getInterval(x, A + 1, A * B)
		for (d, v) in process.items():
			(sx0, lx0) = sumProdOneDivider(d, B * (x - 1))
			(sx1, lx1) = sumProdOneDivider(d, B * x)
			s += v * (sx1 - sx0)
			l += v * (lx1 - lx0)
	return (s, l)

def sumXor(A, B):
	if B < 100:
		return sumXorRef(A, B)
	b = B - 100
	s = b * (b + 1) // 2
	l = b + 1
	all = set()
	for x in range(1, A + 1):
		for y in range(b + 1, B + 1):
			xy = x ^ y
			if xy <= b:
				continue
			all.add(xy)
	s += sum(all)
	l += len(all)
	return (s, l)
(A, B) = map(int, input().split())
(prod, nprod) = sumProd(A, B)
(xor, nxor) = sumXor(A, B)
result = prod * nxor * pow(10, len('%d' % B) + 1) + nprod * xor
print(result)


def gcd(x, y):
	while y != 0:
		(x, y) = (y, x % y)
	return x

def sumProdRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x * y)
	return (sum(all), len(all))

def sumXorRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x ^ y)
	return (sum(all), len(all))

def sumProdOneDivider(divider, limit):
	count = limit // divider
	return (divider * (count + 1) * count // 2, count)

def get(result, x, limit):
	items = result.items()[:]
	if x not in result:
		result[x] = 0
	result[x] += 1
	if result[x] == 0:
		del result[x]
	for (d, v) in items:
		dx = d * x
		if dx > limit:
			continue
		if dx not in result:
			result[dx] = 0
		result[dx] -= v
		if result[dx] == 0:
			del result[dx]
	return result

def getInterval(start, finish, limit):
	result = {}
	for x in range(start, finish):
		items = list(result.items())[:]
		isdiv = False
		for d in range(start, x):
			if x % d == 0:
				isdiv = True
				break
		if isdiv:
			continue
		result[x] = 1
		for (d, v) in items:
			dx = d * x // gcd(d, x)
			if dx > limit:
				continue
			if dx not in result:
				result[dx] = 0
			result[dx] -= v
			if result[dx] == 0:
				del result[dx]
	return result

def sumProd(A, B):
	all = set()
	s = 0
	l = 0
	for x in range(A, 0, -1):
		process = getInterval(x, A + 1, A * B)
		for (d, v) in process.items():
			(sx0, lx0) = sumProdOneDivider(d, B * (x - 1))
			(sx1, lx1) = sumProdOneDivider(d, B * x)
			s += v * (sx1 - sx0)
			l += v * (lx1 - lx0)
	return (s, l)

def sumXor(A, B):
	if B < 100:
		return sumXorRef(A, B)
	b = B - 100
	s = b * (b + 1) // 2
	l = b + 1
	all = set()
	for x in range(1, A + 1):
		for y in range(b + 1, B + 1):
			xy = x ^ y
			if xy <= b:
				continue
			all.add(xy)
	s += sum(all)
	l += len(all)
	return (s, l)
(A, B) = map(int, input().split())
(prod, nprod) = sumProd(A, B)
(xor, nxor) = sumXor(A, B)
result = prod * nxor * pow(10, len('%d' % B) + 1) + nprod * xor
print(result)


def gcd(x, y):
	while y != 0:
		(x, y) = (y, x % y)
	return x

def sumProdRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x * y)
	return (sum(all), len(all))

def sumXorRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x ^ y)
	return (sum(all), len(all))

def sumProdOneDivider(divider, limit):
	count = limit // divider
	return (divider * (count + 1) * count // 2, count)

def get(result, x, limit):
	items = result.items()[:]
	if x not in result:
		result[x] = 0
	result[x] += 1
	if result[x] == 0:
		del result[x]
	for (d, v) in items:
		dx = d * x
		if dx > limit:
			continue
		if dx not in result:
			result[dx] = 0
		result[dx] -= v
		if result[dx] == 0:
			del result[dx]
	return result

def getInterval(start, finish, limit):
	result = {}
	for x in range(start, finish):
		items = list(result.items())[:]
		isdiv = False
		for d in range(start, x):
			if x % d == 0:
				isdiv = True
				break
		if isdiv:
			continue
		result[x] = 1
		for (d, v) in items:
			dx = d * x // gcd(d, x)
			if dx > limit:
				continue
			if dx not in result:
				result[dx] = 0
			result[dx] -= v
			if result[dx] == 0:
				del result[dx]
	return result

def sumProd(A, B):
	all = set()
	s = 0
	l = 0
	for x in range(A, 0, -1):
		process = getInterval(x, A + 1, A * B)
		for (d, v) in process.items():
			(sx0, lx0) = sumProdOneDivider(d, B * (x - 1))
			(sx1, lx1) = sumProdOneDivider(d, B * x)
			s += v * (sx1 - sx0)
			l += v * (lx1 - lx0)
	return (s, l)

def sumXor(A, B):
	if B < 100:
		return sumXorRef(A, B)
	b = B - 100
	s = b * (b + 1) // 2
	l = b + 1
	all = set()
	for x in range(1, A + 1):
		for y in range(b + 1, B + 1):
			xy = x ^ y
			if xy <= b:
				continue
			all.add(xy)
	s += sum(all)
	l += len(all)
	return (s, l)
(A, B) = map(int, input().split())
(prod, nprod) = sumProd(A, B)
(xor, nxor) = sumXor(A, B)
result = prod * nxor * pow(10, len('%d' % B) + 1) + nprod * xor
print(result)


def gcd(x, y):
	while y != 0:
		(x, y) = (y, x % y)
	return x

def sumProdRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x * y)
	return (sum(all), len(all))

def sumXorRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x ^ y)
	return (sum(all), len(all))

def sumProdOneDivider(divider, limit):
	count = limit // divider
	return (divider * (count + 1) * count // 2, count)

def get(result, x, limit):
	items = result.items()[:]
	if x not in result:
		result[x] = 0
	result[x] += 1
	if result[x] == 0:
		del result[x]
	for (d, v) in items:
		dx = d * x
		if dx > limit:
			continue
		if dx not in result:
			result[dx] = 0
		result[dx] -= v
		if result[dx] == 0:
			del result[dx]
	return result

def getInterval(start, finish, limit):
	result = {}
	for x in range(start, finish):
		items = list(result.items())[:]
		isdiv = False
		for d in range(start, x):
			if x % d == 0:
				isdiv = True
				break
		if isdiv:
			continue
		result[x] = 1
		for (d, v) in items:
			dx = d * x // gcd(d, x)
			if dx > limit:
				continue
			if dx not in result:
				result[dx] = 0
			result[dx] -= v
			if result[dx] == 0:
				del result[dx]
	return result

def sumProd(A, B):
	all = set()
	s = 0
	l = 0
	for x in range(A, 0, -1):
		process = getInterval(x, A + 1, A * B)
		for (d, v) in process.items():
			(sx0, lx0) = sumProdOneDivider(d, B * (x - 1))
			(sx1, lx1) = sumProdOneDivider(d, B * x)
			s += v * (sx1 - sx0)
			l += v * (lx1 - lx0)
	return (s, l)

def sumXor(A, B):
	if B < 100:
		return sumXorRef(A, B)
	b = B - 100
	s = b * (b + 1) // 2
	l = b + 1
	all = set()
	for x in range(1, A + 1):
		for y in range(b + 1, B + 1):
			xy = x ^ y
			if xy <= b:
				continue
			all.add(xy)
	s += sum(all)
	l += len(all)
	return (s, l)
(A, B) = map(int, input().split())
(prod, nprod) = sumProd(A, B)
(xor, nxor) = sumXor(A, B)
result = prod * nxor * pow(10, len('%d' % B) + 1) + nprod * xor
print(result)


def gcd(x, y):
	while y != 0:
		(x, y) = (y, x % y)
	return x

def sumProdRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x * y)
	return (sum(all), len(all))

def sumXorRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x ^ y)
	return (sum(all), len(all))

def sumProdOneDivider(divider, limit):
	count = limit // divider
	return (divider * (count + 1) * count // 2, count)

def get(result, x, limit):
	items = result.items()[:]
	if x not in result:
		result[x] = 0
	result[x] += 1
	if result[x] == 0:
		del result[x]
	for (d, v) in items:
		dx = d * x
		if dx > limit:
			continue
		if dx not in result:
			result[dx] = 0
		result[dx] -= v
		if result[dx] == 0:
			del result[dx]
	return result

def getInterval(start, finish, limit):
	result = {}
	for x in range(start, finish):
		items = list(result.items())[:]
		isdiv = False
		for d in range(start, x):
			if x % d == 0:
				isdiv = True
				break
		if isdiv:
			continue
		result[x] = 1
		for (d, v) in items:
			dx = d * x // gcd(d, x)
			if dx > limit:
				continue
			if dx not in result:
				result[dx] = 0
			result[dx] -= v
			if result[dx] == 0:
				del result[dx]
	return result

def sumProd(A, B):
	all = set()
	s = 0
	l = 0
	for x in range(A, 0, -1):
		process = getInterval(x, A + 1, A * B)
		for (d, v) in process.items():
			(sx0, lx0) = sumProdOneDivider(d, B * (x - 1))
			(sx1, lx1) = sumProdOneDivider(d, B * x)
			s += v * (sx1 - sx0)
			l += v * (lx1 - lx0)
	return (s, l)

def sumXor(A, B):
	if B < 100:
		return sumXorRef(A, B)
	b = B - 100
	s = b * (b + 1) // 2
	l = b + 1
	all = set()
	for x in range(1, A + 1):
		for y in range(b + 1, B + 1):
			xy = x ^ y
			if xy <= b:
				continue
			all.add(xy)
	s += sum(all)
	l += len(all)
	return (s, l)
(A, B) = map(int, input().split())
(prod, nprod) = sumProd(A, B)
(xor, nxor) = sumXor(A, B)
result = prod * nxor * pow(10, len('%d' % B) + 1) + nprod * xor
print(result)


def gcd(x, y):
	while y != 0:
		(x, y) = (y, x % y)
	return x

def sumProdRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x * y)
	return (sum(all), len(all))

def sumXorRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x ^ y)
	return (sum(all), len(all))

def sumProdOneDivider(divider, limit):
	count = limit // divider
	return (divider * (count + 1) * count // 2, count)

def get(result, x, limit):
	items = result.items()[:]
	if x not in result:
		result[x] = 0
	result[x] += 1
	if result[x] == 0:
		del result[x]
	for (d, v) in items:
		dx = d * x
		if dx > limit:
			continue
		if dx not in result:
			result[dx] = 0
		result[dx] -= v
		if result[dx] == 0:
			del result[dx]
	return result

def getInterval(start, finish, limit):
	result = {}
	for x in range(start, finish):
		items = list(result.items())[:]
		isdiv = False
		for d in range(start, x):
			if x % d == 0:
				isdiv = True
				break
		if isdiv:
			continue
		result[x] = 1
		for (d, v) in items:
			dx = d * x // gcd(d, x)
			if dx > limit:
				continue
			if dx not in result:
				result[dx] = 0
			result[dx] -= v
			if result[dx] == 0:
				del result[dx]
	return result

def sumProd(A, B):
	all = set()
	s = 0
	l = 0
	for x in range(A, 0, -1):
		process = getInterval(x, A + 1, A * B)
		for (d, v) in process.items():
			(sx0, lx0) = sumProdOneDivider(d, B * (x - 1))
			(sx1, lx1) = sumProdOneDivider(d, B * x)
			s += v * (sx1 - sx0)
			l += v * (lx1 - lx0)
	return (s, l)

def sumXor(A, B):
	if B < 100:
		return sumXorRef(A, B)
	b = B - 100
	s = b * (b + 1) // 2
	l = b + 1
	all = set()
	for x in range(1, A + 1):
		for y in range(b + 1, B + 1):
			xy = x ^ y
			if xy <= b:
				continue
			all.add(xy)
	s += sum(all)
	l += len(all)
	return (s, l)
(A, B) = map(int, input().split())
(prod, nprod) = sumProd(A, B)
(xor, nxor) = sumXor(A, B)
result = prod * nxor * pow(10, len('%d' % B) + 1) + nprod * xor
print(result)


def gcd(x, y):
	while y != 0:
		(x, y) = (y, x % y)
	return x

def sumProdRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x * y)
	return (sum(all), len(all))

def sumXorRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x ^ y)
	return (sum(all), len(all))

def sumProdOneDivider(divider, limit):
	count = limit // divider
	return (divider * (count + 1) * count // 2, count)

def get(result, x, limit):
	items = result.items()[:]
	if x not in result:
		result[x] = 0
	result[x] += 1
	if result[x] == 0:
		del result[x]
	for (d, v) in items:
		dx = d * x
		if dx > limit:
			continue
		if dx not in result:
			result[dx] = 0
		result[dx] -= v
		if result[dx] == 0:
			del result[dx]
	return result

def getInterval(start, finish, limit):
	result = {}
	for x in range(start, finish):
		items = list(result.items())[:]
		isdiv = False
		for d in range(start, x):
			if x % d == 0:
				isdiv = True
				break
		if isdiv:
			continue
		result[x] = 1
		for (d, v) in items:
			dx = d * x // gcd(d, x)
			if dx > limit:
				continue
			if dx not in result:
				result[dx] = 0
			result[dx] -= v
			if result[dx] == 0:
				del result[dx]
	return result

def sumProd(A, B):
	all = set()
	s = 0
	l = 0
	for x in range(A, 0, -1):
		process = getInterval(x, A + 1, A * B)
		for (d, v) in process.items():
			(sx0, lx0) = sumProdOneDivider(d, B * (x - 1))
			(sx1, lx1) = sumProdOneDivider(d, B * x)
			s += v * (sx1 - sx0)
			l += v * (lx1 - lx0)
	return (s, l)

def sumXor(A, B):
	if B < 100:
		return sumXorRef(A, B)
	b = B - 100
	s = b * (b + 1) // 2
	l = b + 1
	all = set()
	for x in range(1, A + 1):
		for y in range(b + 1, B + 1):
			xy = x ^ y
			if xy <= b:
				continue
			all.add(xy)
	s += sum(all)
	l += len(all)
	return (s, l)
(A, B) = map(int, input().split())
(prod, nprod) = sumProd(A, B)
(xor, nxor) = sumXor(A, B)
result = prod * nxor * pow(10, len('%d' % B) + 1) + nprod * xor
print(result)


def gcd(x, y):
	while y != 0:
		(x, y) = (y, x % y)
	return x

def sumProdRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x * y)
	return (sum(all), len(all))

def sumXorRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x ^ y)
	return (sum(all), len(all))

def sumProdOneDivider(divider, limit):
	count = limit // divider
	return (divider * (count + 1) * count // 2, count)

def get(result, x, limit):
	items = result.items()[:]
	if x not in result:
		result[x] = 0
	result[x] += 1
	if result[x] == 0:
		del result[x]
	for (d, v) in items:
		dx = d * x
		if dx > limit:
			continue
		if dx not in result:
			result[dx] = 0
		result[dx] -= v
		if result[dx] == 0:
			del result[dx]
	return result

def getInterval(start, finish, limit):
	result = {}
	for x in range(start, finish):
		items = list(result.items())[:]
		isdiv = False
		for d in range(start, x):
			if x % d == 0:
				isdiv = True
				break
		if isdiv:
			continue
		result[x] = 1
		for (d, v) in items:
			dx = d * x // gcd(d, x)
			if dx > limit:
				continue
			if dx not in result:
				result[dx] = 0
			result[dx] -= v
			if result[dx] == 0:
				del result[dx]
	return result

def sumProd(A, B):
	all = set()
	s = 0
	l = 0
	for x in range(A, 0, -1):
		process = getInterval(x, A + 1, A * B)
		for (d, v) in process.items():
			(sx0, lx0) = sumProdOneDivider(d, B * (x - 1))
			(sx1, lx1) = sumProdOneDivider(d, B * x)
			s += v * (sx1 - sx0)
			l += v * (lx1 - lx0)
	return (s, l)

def sumXor(A, B):
	if B < 100:
		return sumXorRef(A, B)
	b = B - 100
	s = b * (b + 1) // 2
	l = b + 1
	all = set()
	for x in range(1, A + 1):
		for y in range(b + 1, B + 1):
			xy = x ^ y
			if xy <= b:
				continue
			all.add(xy)
	s += sum(all)
	l += len(all)
	return (s, l)
(A, B) = map(int, input().split())
(prod, nprod) = sumProd(A, B)
(xor, nxor) = sumXor(A, B)
result = prod * nxor * pow(10, len('%d' % B) + 1) + nprod * xor
print(result)


def gcd(x, y):
	while y != 0:
		(x, y) = (y, x % y)
	return x

def sumProdRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x * y)
	return (sum(all), len(all))

def sumXorRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x ^ y)
	return (sum(all), len(all))

def sumProdOneDivider(divider, limit):
	count = limit // divider
	return (divider * (count + 1) * count // 2, count)

def get(result, x, limit):
	items = result.items()[:]
	if x not in result:
		result[x] = 0
	result[x] += 1
	if result[x] == 0:
		del result[x]
	for (d, v) in items:
		dx = d * x
		if dx > limit:
			continue
		if dx not in result:
			result[dx] = 0
		result[dx] -= v
		if result[dx] == 0:
			del result[dx]
	return result

def getInterval(start, finish, limit):
	result = {}
	for x in range(start, finish):
		items = list(result.items())[:]
		isdiv = False
		for d in range(start, x):
			if x % d == 0:
				isdiv = True
				break
		if isdiv:
			continue
		result[x] = 1
		for (d, v) in items:
			dx = d * x // gcd(d, x)
			if dx > limit:
				continue
			if dx not in result:
				result[dx] = 0
			result[dx] -= v
			if result[dx] == 0:
				del result[dx]
	return result

def sumProd(A, B):
	all = set()
	s = 0
	l = 0
	for x in range(A, 0, -1):
		process = getInterval(x, A + 1, A * B)
		for (d, v) in process.items():
			(sx0, lx0) = sumProdOneDivider(d, B * (x - 1))
			(sx1, lx1) = sumProdOneDivider(d, B * x)
			s += v * (sx1 - sx0)
			l += v * (lx1 - lx0)
	return (s, l)

def sumXor(A, B):
	if B < 100:
		return sumXorRef(A, B)
	b = B - 100
	s = b * (b + 1) // 2
	l = b + 1
	all = set()
	for x in range(1, A + 1):
		for y in range(b + 1, B + 1):
			xy = x ^ y
			if xy <= b:
				continue
			all.add(xy)
	s += sum(all)
	l += len(all)
	return (s, l)
(A, B) = map(int, input().split())
(prod, nprod) = sumProd(A, B)
(xor, nxor) = sumXor(A, B)
result = prod * nxor * pow(10, len('%d' % B) + 1) + nprod * xor
print(result)


def gcd(x, y):
	while y != 0:
		(x, y) = (y, x % y)
	return x

def sumProdRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x * y)
	return (sum(all), len(all))

def sumXorRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x ^ y)
	return (sum(all), len(all))

def sumProdOneDivider(divider, limit):
	count = limit // divider
	return (divider * (count + 1) * count // 2, count)

def get(result, x, limit):
	items = result.items()[:]
	if x not in result:
		result[x] = 0
	result[x] += 1
	if result[x] == 0:
		del result[x]
	for (d, v) in items:
		dx = d * x
		if dx > limit:
			continue
		if dx not in result:
			result[dx] = 0
		result[dx] -= v
		if result[dx] == 0:
			del result[dx]
	return result

def getInterval(start, finish, limit):
	result = {}
	for x in range(start, finish):
		items = list(result.items())[:]
		isdiv = False
		for d in range(start, x):
			if x % d == 0:
				isdiv = True
				break
		if isdiv:
			continue
		result[x] = 1
		for (d, v) in items:
			dx = d * x // gcd(d, x)
			if dx > limit:
				continue
			if dx not in result:
				result[dx] = 0
			result[dx] -= v
			if result[dx] == 0:
				del result[dx]
	return result

def sumProd(A, B):
	all = set()
	s = 0
	l = 0
	for x in range(A, 0, -1):
		process = getInterval(x, A + 1, A * B)
		for (d, v) in process.items():
			(sx0, lx0) = sumProdOneDivider(d, B * (x - 1))
			(sx1, lx1) = sumProdOneDivider(d, B * x)
			s += v * (sx1 - sx0)
			l += v * (lx1 - lx0)
	return (s, l)

def sumXor(A, B):
	if B < 100:
		return sumXorRef(A, B)
	b = B - 100
	s = b * (b + 1) // 2
	l = b + 1
	all = set()
	for x in range(1, A + 1):
		for y in range(b + 1, B + 1):
			xy = x ^ y
			if xy <= b:
				continue
			all.add(xy)
	s += sum(all)
	l += len(all)
	return (s, l)
(A, B) = map(int, input().split())
(prod, nprod) = sumProd(A, B)
(xor, nxor) = sumXor(A, B)
result = prod * nxor * pow(10, len('%d' % B) + 1) + nprod * xor
print(result)


def gcd(x, y):
	while y != 0:
		(x, y) = (y, x % y)
	return x

def sumProdRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x * y)
	return (sum(all), len(all))

def sumXorRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x ^ y)
	return (sum(all), len(all))

def sumProdOneDivider(divider, limit):
	count = limit // divider
	return (divider * (count + 1) * count // 2, count)

def get(result, x, limit):
	items = result.items()[:]
	if x not in result:
		result[x] = 0
	result[x] += 1
	if result[x] == 0:
		del result[x]
	for (d, v) in items:
		dx = d * x
		if dx > limit:
			continue
		if dx not in result:
			result[dx] = 0
		result[dx] -= v
		if result[dx] == 0:
			del result[dx]
	return result

def getInterval(start, finish, limit):
	result = {}
	for x in range(start, finish):
		items = list(result.items())[:]
		isdiv = False
		for d in range(start, x):
			if x % d == 0:
				isdiv = True
				break
		if isdiv:
			continue
		result[x] = 1
		for (d, v) in items:
			dx = d * x // gcd(d, x)
			if dx > limit:
				continue
			if dx not in result:
				result[dx] = 0
			result[dx] -= v
			if result[dx] == 0:
				del result[dx]
	return result

def sumProd(A, B):
	all = set()
	s = 0
	l = 0
	for x in range(A, 0, -1):
		process = getInterval(x, A + 1, A * B)
		for (d, v) in process.items():
			(sx0, lx0) = sumProdOneDivider(d, B * (x - 1))
			(sx1, lx1) = sumProdOneDivider(d, B * x)
			s += v * (sx1 - sx0)
			l += v * (lx1 - lx0)
	return (s, l)

def sumXor(A, B):
	if B < 100:
		return sumXorRef(A, B)
	b = B - 100
	s = b * (b + 1) // 2
	l = b + 1
	all = set()
	for x in range(1, A + 1):
		for y in range(b + 1, B + 1):
			xy = x ^ y
			if xy <= b:
				continue
			all.add(xy)
	s += sum(all)
	l += len(all)
	return (s, l)
(A, B) = map(int, input().split())
(prod, nprod) = sumProd(A, B)
(xor, nxor) = sumXor(A, B)
result = prod * nxor * pow(10, len('%d' % B) + 1) + nprod * xor
print(result)


def gcd(x, y):
	while y != 0:
		(x, y) = (y, x % y)
	return x

def sumProdRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x * y)
	return (sum(all), len(all))

def sumXorRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x ^ y)
	return (sum(all), len(all))

def sumProdOneDivider(divider, limit):
	count = limit // divider
	return (divider * (count + 1) * count // 2, count)

def get(result, x, limit):
	items = result.items()[:]
	if x not in result:
		result[x] = 0
	result[x] += 1
	if result[x] == 0:
		del result[x]
	for (d, v) in items:
		dx = d * x
		if dx > limit:
			continue
		if dx not in result:
			result[dx] = 0
		result[dx] -= v
		if result[dx] == 0:
			del result[dx]
	return result

def getInterval(start, finish, limit):
	result = {}
	for x in range(start, finish):
		items = list(result.items())[:]
		isdiv = False
		for d in range(start, x):
			if x % d == 0:
				isdiv = True
				break
		if isdiv:
			continue
		result[x] = 1
		for (d, v) in items:
			dx = d * x // gcd(d, x)
			if dx > limit:
				continue
			if dx not in result:
				result[dx] = 0
			result[dx] -= v
			if result[dx] == 0:
				del result[dx]
	return result

def sumProd(A, B):
	all = set()
	s = 0
	l = 0
	for x in range(A, 0, -1):
		process = getInterval(x, A + 1, A * B)
		for (d, v) in process.items():
			(sx0, lx0) = sumProdOneDivider(d, B * (x - 1))
			(sx1, lx1) = sumProdOneDivider(d, B * x)
			s += v * (sx1 - sx0)
			l += v * (lx1 - lx0)
	return (s, l)

def sumXor(A, B):
	if B < 100:
		return sumXorRef(A, B)
	b = B - 100
	s = b * (b + 1) // 2
	l = b + 1
	all = set()
	for x in range(1, A + 1):
		for y in range(b + 1, B + 1):
			xy = x ^ y
			if xy <= b:
				continue
			all.add(xy)
	s += sum(all)
	l += len(all)
	return (s, l)
(A, B) = map(int, input().split())
(prod, nprod) = sumProd(A, B)
(xor, nxor) = sumXor(A, B)
result = prod * nxor * pow(10, len('%d' % B) + 1) + nprod * xor
print(result)


def gcd(x, y):
	while y != 0:
		(x, y) = (y, x % y)
	return x

def sumProdRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x * y)
	return (sum(all), len(all))

def sumXorRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x ^ y)
	return (sum(all), len(all))

def sumProdOneDivider(divider, limit):
	count = limit // divider
	return (divider * (count + 1) * count // 2, count)

def get(result, x, limit):
	items = result.items()[:]
	if x not in result:
		result[x] = 0
	result[x] += 1
	if result[x] == 0:
		del result[x]
	for (d, v) in items:
		dx = d * x
		if dx > limit:
			continue
		if dx not in result:
			result[dx] = 0
		result[dx] -= v
		if result[dx] == 0:
			del result[dx]
	return result

def getInterval(start, finish, limit):
	result = {}
	for x in range(start, finish):
		items = list(result.items())[:]
		isdiv = False
		for d in range(start, x):
			if x % d == 0:
				isdiv = True
				break
		if isdiv:
			continue
		result[x] = 1
		for (d, v) in items:
			dx = d * x // gcd(d, x)
			if dx > limit:
				continue
			if dx not in result:
				result[dx] = 0
			result[dx] -= v
			if result[dx] == 0:
				del result[dx]
	return result

def sumProd(A, B):
	all = set()
	s = 0
	l = 0
	for x in range(A, 0, -1):
		process = getInterval(x, A + 1, A * B)
		for (d, v) in process.items():
			(sx0, lx0) = sumProdOneDivider(d, B * (x - 1))
			(sx1, lx1) = sumProdOneDivider(d, B * x)
			s += v * (sx1 - sx0)
			l += v * (lx1 - lx0)
	return (s, l)

def sumXor(A, B):
	if B < 100:
		return sumXorRef(A, B)
	b = B - 100
	s = b * (b + 1) // 2
	l = b + 1
	all = set()
	for x in range(1, A + 1):
		for y in range(b + 1, B + 1):
			xy = x ^ y
			if xy <= b:
				continue
			all.add(xy)
	s += sum(all)
	l += len(all)
	return (s, l)
(A, B) = map(int, input().split())
(prod, nprod) = sumProd(A, B)
(xor, nxor) = sumXor(A, B)
result = prod * nxor * pow(10, len('%d' % B) + 1) + nprod * xor
print(result)


def gcd(x, y):
	while y != 0:
		(x, y) = (y, x % y)
	return x

def sumProdRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x * y)
	return (sum(all), len(all))

def sumXorRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x ^ y)
	return (sum(all), len(all))

def sumProdOneDivider(divider, limit):
	count = limit // divider
	return (divider * (count + 1) * count // 2, count)

def get(result, x, limit):
	items = result.items()[:]
	if x not in result:
		result[x] = 0
	result[x] += 1
	if result[x] == 0:
		del result[x]
	for (d, v) in items:
		dx = d * x
		if dx > limit:
			continue
		if dx not in result:
			result[dx] = 0
		result[dx] -= v
		if result[dx] == 0:
			del result[dx]
	return result

def getInterval(start, finish, limit):
	result = {}
	for x in range(start, finish):
		items = list(result.items())[:]
		isdiv = False
		for d in range(start, x):
			if x % d == 0:
				isdiv = True
				break
		if isdiv:
			continue
		result[x] = 1
		for (d, v) in items:
			dx = d * x // gcd(d, x)
			if dx > limit:
				continue
			if dx not in result:
				result[dx] = 0
			result[dx] -= v
			if result[dx] == 0:
				del result[dx]
	return result

def sumProd(A, B):
	all = set()
	s = 0
	l = 0
	for x in range(A, 0, -1):
		process = getInterval(x, A + 1, A * B)
		for (d, v) in process.items():
			(sx0, lx0) = sumProdOneDivider(d, B * (x - 1))
			(sx1, lx1) = sumProdOneDivider(d, B * x)
			s += v * (sx1 - sx0)
			l += v * (lx1 - lx0)
	return (s, l)

def sumXor(A, B):
	if B < 100:
		return sumXorRef(A, B)
	b = B - 100
	s = b * (b + 1) // 2
	l = b + 1
	all = set()
	for x in range(1, A + 1):
		for y in range(b + 1, B + 1):
			xy = x ^ y
			if xy <= b:
				continue
			all.add(xy)
	s += sum(all)
	l += len(all)
	return (s, l)
(A, B) = map(int, input().split())
(prod, nprod) = sumProd(A, B)
(xor, nxor) = sumXor(A, B)
result = prod * nxor * pow(10, len('%d' % B) + 1) + nprod * xor
print(result)


def gcd(x, y):
	while y != 0:
		(x, y) = (y, x % y)
	return x

def sumProdRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x * y)
	return (sum(all), len(all))

def sumXorRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x ^ y)
	return (sum(all), len(all))

def sumProdOneDivider(divider, limit):
	count = limit // divider
	return (divider * (count + 1) * count // 2, count)

def get(result, x, limit):
	items = result.items()[:]
	if x not in result:
		result[x] = 0
	result[x] += 1
	if result[x] == 0:
		del result[x]
	for (d, v) in items:
		dx = d * x
		if dx > limit:
			continue
		if dx not in result:
			result[dx] = 0
		result[dx] -= v
		if result[dx] == 0:
			del result[dx]
	return result

def getInterval(start, finish, limit):
	result = {}
	for x in range(start, finish):
		items = list(result.items())[:]
		isdiv = False
		for d in range(start, x):
			if x % d == 0:
				isdiv = True
				break
		if isdiv:
			continue
		result[x] = 1
		for (d, v) in items:
			dx = d * x // gcd(d, x)
			if dx > limit:
				continue
			if dx not in result:
				result[dx] = 0
			result[dx] -= v
			if result[dx] == 0:
				del result[dx]
	return result

def sumProd(A, B):
	all = set()
	s = 0
	l = 0
	for x in range(A, 0, -1):
		process = getInterval(x, A + 1, A * B)
		for (d, v) in process.items():
			(sx0, lx0) = sumProdOneDivider(d, B * (x - 1))
			(sx1, lx1) = sumProdOneDivider(d, B * x)
			s += v * (sx1 - sx0)
			l += v * (lx1 - lx0)
	return (s, l)

def sumXor(A, B):
	if B < 100:
		return sumXorRef(A, B)
	b = B - 100
	s = b * (b + 1) // 2
	l = b + 1
	all = set()
	for x in range(1, A + 1):
		for y in range(b + 1, B + 1):
			xy = x ^ y
			if xy <= b:
				continue
			all.add(xy)
	s += sum(all)
	l += len(all)
	return (s, l)
(A, B) = map(int, input().split())
(prod, nprod) = sumProd(A, B)
(xor, nxor) = sumXor(A, B)
result = prod * nxor * pow(10, len('%d' % B) + 1) + nprod * xor
print(result)


def gcd(x, y):
	while y != 0:
		(x, y) = (y, x % y)
	return x

def sumProdRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x * y)
	return (sum(all), len(all))

def sumXorRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x ^ y)
	return (sum(all), len(all))

def sumProdOneDivider(divider, limit):
	count = limit // divider
	return (divider * (count + 1) * count // 2, count)

def get(result, x, limit):
	items = result.items()[:]
	if x not in result:
		result[x] = 0
	result[x] += 1
	if result[x] == 0:
		del result[x]
	for (d, v) in items:
		dx = d * x
		if dx > limit:
			continue
		if dx not in result:
			result[dx] = 0
		result[dx] -= v
		if result[dx] == 0:
			del result[dx]
	return result

def getInterval(start, finish, limit):
	result = {}
	for x in range(start, finish):
		items = list(result.items())[:]
		isdiv = False
		for d in range(start, x):
			if x % d == 0:
				isdiv = True
				break
		if isdiv:
			continue
		result[x] = 1
		for (d, v) in items:
			dx = d * x // gcd(d, x)
			if dx > limit:
				continue
			if dx not in result:
				result[dx] = 0
			result[dx] -= v
			if result[dx] == 0:
				del result[dx]
	return result

def sumProd(A, B):
	all = set()
	s = 0
	l = 0
	for x in range(A, 0, -1):
		process = getInterval(x, A + 1, A * B)
		for (d, v) in process.items():
			(sx0, lx0) = sumProdOneDivider(d, B * (x - 1))
			(sx1, lx1) = sumProdOneDivider(d, B * x)
			s += v * (sx1 - sx0)
			l += v * (lx1 - lx0)
	return (s, l)

def sumXor(A, B):
	if B < 100:
		return sumXorRef(A, B)
	b = B - 100
	s = b * (b + 1) // 2
	l = b + 1
	all = set()
	for x in range(1, A + 1):
		for y in range(b + 1, B + 1):
			xy = x ^ y
			if xy <= b:
				continue
			all.add(xy)
	s += sum(all)
	l += len(all)
	return (s, l)
(A, B) = map(int, input().split())
(prod, nprod) = sumProd(A, B)
(xor, nxor) = sumXor(A, B)
result = prod * nxor * pow(10, len('%d' % B) + 1) + nprod * xor
print(result)


def gcd(x, y):
	while y != 0:
		(x, y) = (y, x % y)
	return x

def sumProdRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x * y)
	return (sum(all), len(all))

def sumXorRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x ^ y)
	return (sum(all), len(all))

def sumProdOneDivider(divider, limit):
	count = limit // divider
	return (divider * (count + 1) * count // 2, count)

def get(result, x, limit):
	items = result.items()[:]
	if x not in result:
		result[x] = 0
	result[x] += 1
	if result[x] == 0:
		del result[x]
	for (d, v) in items:
		dx = d * x
		if dx > limit:
			continue
		if dx not in result:
			result[dx] = 0
		result[dx] -= v
		if result[dx] == 0:
			del result[dx]
	return result

def getInterval(start, finish, limit):
	result = {}
	for x in range(start, finish):
		items = list(result.items())[:]
		isdiv = False
		for d in range(start, x):
			if x % d == 0:
				isdiv = True
				break
		if isdiv:
			continue
		result[x] = 1
		for (d, v) in items:
			dx = d * x // gcd(d, x)
			if dx > limit:
				continue
			if dx not in result:
				result[dx] = 0
			result[dx] -= v
			if result[dx] == 0:
				del result[dx]
	return result

def sumProd(A, B):
	all = set()
	s = 0
	l = 0
	for x in range(A, 0, -1):
		process = getInterval(x, A + 1, A * B)
		for (d, v) in process.items():
			(sx0, lx0) = sumProdOneDivider(d, B * (x - 1))
			(sx1, lx1) = sumProdOneDivider(d, B * x)
			s += v * (sx1 - sx0)
			l += v * (lx1 - lx0)
	return (s, l)

def sumXor(A, B):
	if B < 100:
		return sumXorRef(A, B)
	b = B - 100
	s = b * (b + 1) // 2
	l = b + 1
	all = set()
	for x in range(1, A + 1):
		for y in range(b + 1, B + 1):
			xy = x ^ y
			if xy <= b:
				continue
			all.add(xy)
	s += sum(all)
	l += len(all)
	return (s, l)
(A, B) = map(int, input().split())
(prod, nprod) = sumProd(A, B)
(xor, nxor) = sumXor(A, B)
result = prod * nxor * pow(10, len('%d' % B) + 1) + nprod * xor
print(result)


def gcd(x, y):
	while y != 0:
		(x, y) = (y, x % y)
	return x

def sumProdRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x * y)
	return (sum(all), len(all))

def sumXorRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x ^ y)
	return (sum(all), len(all))

def sumProdOneDivider(divider, limit):
	count = limit // divider
	return (divider * (count + 1) * count // 2, count)

def get(result, x, limit):
	items = result.items()[:]
	if x not in result:
		result[x] = 0
	result[x] += 1
	if result[x] == 0:
		del result[x]
	for (d, v) in items:
		dx = d * x
		if dx > limit:
			continue
		if dx not in result:
			result[dx] = 0
		result[dx] -= v
		if result[dx] == 0:
			del result[dx]
	return result

def getInterval(start, finish, limit):
	result = {}
	for x in range(start, finish):
		items = list(result.items())[:]
		isdiv = False
		for d in range(start, x):
			if x % d == 0:
				isdiv = True
				break
		if isdiv:
			continue
		result[x] = 1
		for (d, v) in items:
			dx = d * x // gcd(d, x)
			if dx > limit:
				continue
			if dx not in result:
				result[dx] = 0
			result[dx] -= v
			if result[dx] == 0:
				del result[dx]
	return result

def sumProd(A, B):
	all = set()
	s = 0
	l = 0
	for x in range(A, 0, -1):
		process = getInterval(x, A + 1, A * B)
		for (d, v) in process.items():
			(sx0, lx0) = sumProdOneDivider(d, B * (x - 1))
			(sx1, lx1) = sumProdOneDivider(d, B * x)
			s += v * (sx1 - sx0)
			l += v * (lx1 - lx0)
	return (s, l)

def sumXor(A, B):
	if B < 100:
		return sumXorRef(A, B)
	b = B - 100
	s = b * (b + 1) // 2
	l = b + 1
	all = set()
	for x in range(1, A + 1):
		for y in range(b + 1, B + 1):
			xy = x ^ y
			if xy <= b:
				continue
			all.add(xy)
	s += sum(all)
	l += len(all)
	return (s, l)
(A, B) = map(int, input().split())
(prod, nprod) = sumProd(A, B)
(xor, nxor) = sumXor(A, B)
result = prod * nxor * pow(10, len('%d' % B) + 1) + nprod * xor
print(result)


def gcd(x, y):
	while y != 0:
		(x, y) = (y, x % y)
	return x

def sumProdRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x * y)
	return (sum(all), len(all))

def sumXorRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x ^ y)
	return (sum(all), len(all))

def sumProdOneDivider(divider, limit):
	count = limit // divider
	return (divider * (count + 1) * count // 2, count)

def get(result, x, limit):
	items = result.items()[:]
	if x not in result:
		result[x] = 0
	result[x] += 1
	if result[x] == 0:
		del result[x]
	for (d, v) in items:
		dx = d * x
		if dx > limit:
			continue
		if dx not in result:
			result[dx] = 0
		result[dx] -= v
		if result[dx] == 0:
			del result[dx]
	return result

def getInterval(start, finish, limit):
	result = {}
	for x in range(start, finish):
		items = list(result.items())[:]
		isdiv = False
		for d in range(start, x):
			if x % d == 0:
				isdiv = True
				break
		if isdiv:
			continue
		result[x] = 1
		for (d, v) in items:
			dx = d * x // gcd(d, x)
			if dx > limit:
				continue
			if dx not in result:
				result[dx] = 0
			result[dx] -= v
			if result[dx] == 0:
				del result[dx]
	return result

def sumProd(A, B):
	all = set()
	s = 0
	l = 0
	for x in range(A, 0, -1):
		process = getInterval(x, A + 1, A * B)
		for (d, v) in process.items():
			(sx0, lx0) = sumProdOneDivider(d, B * (x - 1))
			(sx1, lx1) = sumProdOneDivider(d, B * x)
			s += v * (sx1 - sx0)
			l += v * (lx1 - lx0)
	return (s, l)

def sumXor(A, B):
	if B < 100:
		return sumXorRef(A, B)
	b = B - 100
	s = b * (b + 1) // 2
	l = b + 1
	all = set()
	for x in range(1, A + 1):
		for y in range(b + 1, B + 1):
			xy = x ^ y
			if xy <= b:
				continue
			all.add(xy)
	s += sum(all)
	l += len(all)
	return (s, l)
(A, B) = map(int, input().split())
(prod, nprod) = sumProd(A, B)
(xor, nxor) = sumXor(A, B)
result = prod * nxor * pow(10, len('%d' % B) + 1) + nprod * xor
print(result)


def gcd(x, y):
	while y != 0:
		(x, y) = (y, x % y)
	return x

def sumProdRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x * y)
	return (sum(all), len(all))

def sumXorRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x ^ y)
	return (sum(all), len(all))

def sumProdOneDivider(divider, limit):
	count = limit // divider
	return (divider * (count + 1) * count // 2, count)

def get(result, x, limit):
	items = result.items()[:]
	if x not in result:
		result[x] = 0
	result[x] += 1
	if result[x] == 0:
		del result[x]
	for (d, v) in items:
		dx = d * x
		if dx > limit:
			continue
		if dx not in result:
			result[dx] = 0
		result[dx] -= v
		if result[dx] == 0:
			del result[dx]
	return result

def getInterval(start, finish, limit):
	result = {}
	for x in range(start, finish):
		items = list(result.items())[:]
		isdiv = False
		for d in range(start, x):
			if x % d == 0:
				isdiv = True
				break
		if isdiv:
			continue
		result[x] = 1
		for (d, v) in items:
			dx = d * x // gcd(d, x)
			if dx > limit:
				continue
			if dx not in result:
				result[dx] = 0
			result[dx] -= v
			if result[dx] == 0:
				del result[dx]
	return result

def sumProd(A, B):
	all = set()
	s = 0
	l = 0
	for x in range(A, 0, -1):
		process = getInterval(x, A + 1, A * B)
		for (d, v) in process.items():
			(sx0, lx0) = sumProdOneDivider(d, B * (x - 1))
			(sx1, lx1) = sumProdOneDivider(d, B * x)
			s += v * (sx1 - sx0)
			l += v * (lx1 - lx0)
	return (s, l)

def sumXor(A, B):
	if B < 100:
		return sumXorRef(A, B)
	b = B - 100
	s = b * (b + 1) // 2
	l = b + 1
	all = set()
	for x in range(1, A + 1):
		for y in range(b + 1, B + 1):
			xy = x ^ y
			if xy <= b:
				continue
			all.add(xy)
	s += sum(all)
	l += len(all)
	return (s, l)
(A, B) = map(int, input().split())
(prod, nprod) = sumProd(A, B)
(xor, nxor) = sumXor(A, B)
result = prod * nxor * pow(10, len('%d' % B) + 1) + nprod * xor
print(result)


def gcd(x, y):
	while y != 0:
		(x, y) = (y, x % y)
	return x

def sumProdRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x * y)
	return (sum(all), len(all))

def sumXorRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x ^ y)
	return (sum(all), len(all))

def sumProdOneDivider(divider, limit):
	count = limit // divider
	return (divider * (count + 1) * count // 2, count)

def get(result, x, limit):
	items = result.items()[:]
	if x not in result:
		result[x] = 0
	result[x] += 1
	if result[x] == 0:
		del result[x]
	for (d, v) in items:
		dx = d * x
		if dx > limit:
			continue
		if dx not in result:
			result[dx] = 0
		result[dx] -= v
		if result[dx] == 0:
			del result[dx]
	return result

def getInterval(start, finish, limit):
	result = {}
	for x in range(start, finish):
		items = list(result.items())[:]
		isdiv = False
		for d in range(start, x):
			if x % d == 0:
				isdiv = True
				break
		if isdiv:
			continue
		result[x] = 1
		for (d, v) in items:
			dx = d * x // gcd(d, x)
			if dx > limit:
				continue
			if dx not in result:
				result[dx] = 0
			result[dx] -= v
			if result[dx] == 0:
				del result[dx]
	return result

def sumProd(A, B):
	all = set()
	s = 0
	l = 0
	for x in range(A, 0, -1):
		process = getInterval(x, A + 1, A * B)
		for (d, v) in process.items():
			(sx0, lx0) = sumProdOneDivider(d, B * (x - 1))
			(sx1, lx1) = sumProdOneDivider(d, B * x)
			s += v * (sx1 - sx0)
			l += v * (lx1 - lx0)
	return (s, l)

def sumXor(A, B):
	if B < 100:
		return sumXorRef(A, B)
	b = B - 100
	s = b * (b + 1) // 2
	l = b + 1
	all = set()
	for x in range(1, A + 1):
		for y in range(b + 1, B + 1):
			xy = x ^ y
			if xy <= b:
				continue
			all.add(xy)
	s += sum(all)
	l += len(all)
	return (s, l)
(A, B) = map(int, input().split())
(prod, nprod) = sumProd(A, B)
(xor, nxor) = sumXor(A, B)
result = prod * nxor * pow(10, len('%d' % B) + 1) + nprod * xor
print(result)


def gcd(x, y):
	while y != 0:
		(x, y) = (y, x % y)
	return x

def sumProdRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x * y)
	return (sum(all), len(all))

def sumXorRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x ^ y)
	return (sum(all), len(all))

def sumProdOneDivider(divider, limit):
	count = limit // divider
	return (divider * (count + 1) * count // 2, count)

def get(result, x, limit):
	items = result.items()[:]
	if x not in result:
		result[x] = 0
	result[x] += 1
	if result[x] == 0:
		del result[x]
	for (d, v) in items:
		dx = d * x
		if dx > limit:
			continue
		if dx not in result:
			result[dx] = 0
		result[dx] -= v
		if result[dx] == 0:
			del result[dx]
	return result

def getInterval(start, finish, limit):
	result = {}
	for x in range(start, finish):
		items = list(result.items())[:]
		isdiv = False
		for d in range(start, x):
			if x % d == 0:
				isdiv = True
				break
		if isdiv:
			continue
		result[x] = 1
		for (d, v) in items:
			dx = d * x // gcd(d, x)
			if dx > limit:
				continue
			if dx not in result:
				result[dx] = 0
			result[dx] -= v
			if result[dx] == 0:
				del result[dx]
	return result

def sumProd(A, B):
	all = set()
	s = 0
	l = 0
	for x in range(A, 0, -1):
		process = getInterval(x, A + 1, A * B)
		for (d, v) in process.items():
			(sx0, lx0) = sumProdOneDivider(d, B * (x - 1))
			(sx1, lx1) = sumProdOneDivider(d, B * x)
			s += v * (sx1 - sx0)
			l += v * (lx1 - lx0)
	return (s, l)

def sumXor(A, B):
	if B < 100:
		return sumXorRef(A, B)
	b = B - 100
	s = b * (b + 1) // 2
	l = b + 1
	all = set()
	for x in range(1, A + 1):
		for y in range(b + 1, B + 1):
			xy = x ^ y
			if xy <= b:
				continue
			all.add(xy)
	s += sum(all)
	l += len(all)
	return (s, l)
(A, B) = map(int, input().split())
(prod, nprod) = sumProd(A, B)
(xor, nxor) = sumXor(A, B)
result = prod * nxor * pow(10, len('%d' % B) + 1) + nprod * xor
print(result)


def gcd(x, y):
	while y != 0:
		(x, y) = (y, x % y)
	return x

def sumProdRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x * y)
	return (sum(all), len(all))

def sumXorRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x ^ y)
	return (sum(all), len(all))

def sumProdOneDivider(divider, limit):
	count = limit // divider
	return (divider * (count + 1) * count // 2, count)

def get(result, x, limit):
	items = result.items()[:]
	if x not in result:
		result[x] = 0
	result[x] += 1
	if result[x] == 0:
		del result[x]
	for (d, v) in items:
		dx = d * x
		if dx > limit:
			continue
		if dx not in result:
			result[dx] = 0
		result[dx] -= v
		if result[dx] == 0:
			del result[dx]
	return result

def getInterval(start, finish, limit):
	result = {}
	for x in range(start, finish):
		items = list(result.items())[:]
		isdiv = False
		for d in range(start, x):
			if x % d == 0:
				isdiv = True
				break
		if isdiv:
			continue
		result[x] = 1
		for (d, v) in items:
			dx = d * x // gcd(d, x)
			if dx > limit:
				continue
			if dx not in result:
				result[dx] = 0
			result[dx] -= v
			if result[dx] == 0:
				del result[dx]
	return result

def sumProd(A, B):
	all = set()
	s = 0
	l = 0
	for x in range(A, 0, -1):
		process = getInterval(x, A + 1, A * B)
		for (d, v) in process.items():
			(sx0, lx0) = sumProdOneDivider(d, B * (x - 1))
			(sx1, lx1) = sumProdOneDivider(d, B * x)
			s += v * (sx1 - sx0)
			l += v * (lx1 - lx0)
	return (s, l)

def sumXor(A, B):
	if B < 100:
		return sumXorRef(A, B)
	b = B - 100
	s = b * (b + 1) // 2
	l = b + 1
	all = set()
	for x in range(1, A + 1):
		for y in range(b + 1, B + 1):
			xy = x ^ y
			if xy <= b:
				continue
			all.add(xy)
	s += sum(all)
	l += len(all)
	return (s, l)
(A, B) = map(int, input().split())
(prod, nprod) = sumProd(A, B)
(xor, nxor) = sumXor(A, B)
result = prod * nxor * pow(10, len('%d' % B) + 1) + nprod * xor
print(result)


def gcd(x, y):
	while y != 0:
		(x, y) = (y, x % y)
	return x

def sumProdRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x * y)
	return (sum(all), len(all))

def sumXorRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x ^ y)
	return (sum(all), len(all))

def sumProdOneDivider(divider, limit):
	count = limit // divider
	return (divider * (count + 1) * count // 2, count)

def get(result, x, limit):
	items = result.items()[:]
	if x not in result:
		result[x] = 0
	result[x] += 1
	if result[x] == 0:
		del result[x]
	for (d, v) in items:
		dx = d * x
		if dx > limit:
			continue
		if dx not in result:
			result[dx] = 0
		result[dx] -= v
		if result[dx] == 0:
			del result[dx]
	return result

def getInterval(start, finish, limit):
	result = {}
	for x in range(start, finish):
		items = list(result.items())[:]
		isdiv = False
		for d in range(start, x):
			if x % d == 0:
				isdiv = True
				break
		if isdiv:
			continue
		result[x] = 1
		for (d, v) in items:
			dx = d * x // gcd(d, x)
			if dx > limit:
				continue
			if dx not in result:
				result[dx] = 0
			result[dx] -= v
			if result[dx] == 0:
				del result[dx]
	return result

def sumProd(A, B):
	all = set()
	s = 0
	l = 0
	for x in range(A, 0, -1):
		process = getInterval(x, A + 1, A * B)
		for (d, v) in process.items():
			(sx0, lx0) = sumProdOneDivider(d, B * (x - 1))
			(sx1, lx1) = sumProdOneDivider(d, B * x)
			s += v * (sx1 - sx0)
			l += v * (lx1 - lx0)
	return (s, l)

def sumXor(A, B):
	if B < 100:
		return sumXorRef(A, B)
	b = B - 100
	s = b * (b + 1) // 2
	l = b + 1
	all = set()
	for x in range(1, A + 1):
		for y in range(b + 1, B + 1):
			xy = x ^ y
			if xy <= b:
				continue
			all.add(xy)
	s += sum(all)
	l += len(all)
	return (s, l)
(A, B) = map(int, input().split())
(prod, nprod) = sumProd(A, B)
(xor, nxor) = sumXor(A, B)
result = prod * nxor * pow(10, len('%d' % B) + 1) + nprod * xor
print(result)


def gcd(x, y):
	while y != 0:
		(x, y) = (y, x % y)
	return x

def sumProdRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x * y)
	return (sum(all), len(all))

def sumXorRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x ^ y)
	return (sum(all), len(all))

def sumProdOneDivider(divider, limit):
	count = limit // divider
	return (divider * (count + 1) * count // 2, count)

def get(result, x, limit):
	items = result.items()[:]
	if x not in result:
		result[x] = 0
	result[x] += 1
	if result[x] == 0:
		del result[x]
	for (d, v) in items:
		dx = d * x
		if dx > limit:
			continue
		if dx not in result:
			result[dx] = 0
		result[dx] -= v
		if result[dx] == 0:
			del result[dx]
	return result

def getInterval(start, finish, limit):
	result = {}
	for x in range(start, finish):
		items = list(result.items())[:]
		isdiv = False
		for d in range(start, x):
			if x % d == 0:
				isdiv = True
				break
		if isdiv:
			continue
		result[x] = 1
		for (d, v) in items:
			dx = d * x // gcd(d, x)
			if dx > limit:
				continue
			if dx not in result:
				result[dx] = 0
			result[dx] -= v
			if result[dx] == 0:
				del result[dx]
	return result

def sumProd(A, B):
	all = set()
	s = 0
	l = 0
	for x in range(A, 0, -1):
		process = getInterval(x, A + 1, A * B)
		for (d, v) in process.items():
			(sx0, lx0) = sumProdOneDivider(d, B * (x - 1))
			(sx1, lx1) = sumProdOneDivider(d, B * x)
			s += v * (sx1 - sx0)
			l += v * (lx1 - lx0)
	return (s, l)

def sumXor(A, B):
	if B < 100:
		return sumXorRef(A, B)
	b = B - 100
	s = b * (b + 1) // 2
	l = b + 1
	all = set()
	for x in range(1, A + 1):
		for y in range(b + 1, B + 1):
			xy = x ^ y
			if xy <= b:
				continue
			all.add(xy)
	s += sum(all)
	l += len(all)
	return (s, l)
(A, B) = map(int, input().split())
(prod, nprod) = sumProd(A, B)
(xor, nxor) = sumXor(A, B)
result = prod * nxor * pow(10, len('%d' % B) + 1) + nprod * xor
print(result)


def gcd(x, y):
	while y != 0:
		(x, y) = (y, x % y)
	return x

def sumProdRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x * y)
	return (sum(all), len(all))

def sumXorRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x ^ y)
	return (sum(all), len(all))

def sumProdOneDivider(divider, limit):
	count = limit // divider
	return (divider * (count + 1) * count // 2, count)

def get(result, x, limit):
	items = result.items()[:]
	if x not in result:
		result[x] = 0
	result[x] += 1
	if result[x] == 0:
		del result[x]
	for (d, v) in items:
		dx = d * x
		if dx > limit:
			continue
		if dx not in result:
			result[dx] = 0
		result[dx] -= v
		if result[dx] == 0:
			del result[dx]
	return result

def getInterval(start, finish, limit):
	result = {}
	for x in range(start, finish):
		items = list(result.items())[:]
		isdiv = False
		for d in range(start, x):
			if x % d == 0:
				isdiv = True
				break
		if isdiv:
			continue
		result[x] = 1
		for (d, v) in items:
			dx = d * x // gcd(d, x)
			if dx > limit:
				continue
			if dx not in result:
				result[dx] = 0
			result[dx] -= v
			if result[dx] == 0:
				del result[dx]
	return result

def sumProd(A, B):
	all = set()
	s = 0
	l = 0
	for x in range(A, 0, -1):
		process = getInterval(x, A + 1, A * B)
		for (d, v) in process.items():
			(sx0, lx0) = sumProdOneDivider(d, B * (x - 1))
			(sx1, lx1) = sumProdOneDivider(d, B * x)
			s += v * (sx1 - sx0)
			l += v * (lx1 - lx0)
	return (s, l)

def sumXor(A, B):
	if B < 100:
		return sumXorRef(A, B)
	b = B - 100
	s = b * (b + 1) // 2
	l = b + 1
	all = set()
	for x in range(1, A + 1):
		for y in range(b + 1, B + 1):
			xy = x ^ y
			if xy <= b:
				continue
			all.add(xy)
	s += sum(all)
	l += len(all)
	return (s, l)
(A, B) = map(int, input().split())
(prod, nprod) = sumProd(A, B)
(xor, nxor) = sumXor(A, B)
result = prod * nxor * pow(10, len('%d' % B) + 1) + nprod * xor
print(result)


def gcd(x, y):
	while y != 0:
		(x, y) = (y, x % y)
	return x

def sumProdRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x * y)
	return (sum(all), len(all))

def sumXorRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x ^ y)
	return (sum(all), len(all))

def sumProdOneDivider(divider, limit):
	count = limit // divider
	return (divider * (count + 1) * count // 2, count)

def get(result, x, limit):
	items = result.items()[:]
	if x not in result:
		result[x] = 0
	result[x] += 1
	if result[x] == 0:
		del result[x]
	for (d, v) in items:
		dx = d * x
		if dx > limit:
			continue
		if dx not in result:
			result[dx] = 0
		result[dx] -= v
		if result[dx] == 0:
			del result[dx]
	return result

def getInterval(start, finish, limit):
	result = {}
	for x in range(start, finish):
		items = list(result.items())[:]
		isdiv = False
		for d in range(start, x):
			if x % d == 0:
				isdiv = True
				break
		if isdiv:
			continue
		result[x] = 1
		for (d, v) in items:
			dx = d * x // gcd(d, x)
			if dx > limit:
				continue
			if dx not in result:
				result[dx] = 0
			result[dx] -= v
			if result[dx] == 0:
				del result[dx]
	return result

def sumProd(A, B):
	all = set()
	s = 0
	l = 0
	for x in range(A, 0, -1):
		process = getInterval(x, A + 1, A * B)
		for (d, v) in process.items():
			(sx0, lx0) = sumProdOneDivider(d, B * (x - 1))
			(sx1, lx1) = sumProdOneDivider(d, B * x)
			s += v * (sx1 - sx0)
			l += v * (lx1 - lx0)
	return (s, l)

def sumXor(A, B):
	if B < 100:
		return sumXorRef(A, B)
	b = B - 100
	s = b * (b + 1) // 2
	l = b + 1
	all = set()
	for x in range(1, A + 1):
		for y in range(b + 1, B + 1):
			xy = x ^ y
			if xy <= b:
				continue
			all.add(xy)
	s += sum(all)
	l += len(all)
	return (s, l)
(A, B) = map(int, input().split())
(prod, nprod) = sumProd(A, B)
(xor, nxor) = sumXor(A, B)
result = prod * nxor * pow(10, len('%d' % B) + 1) + nprod * xor
print(result)


def gcd(x, y):
	while y != 0:
		(x, y) = (y, x % y)
	return x

def sumProdRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x * y)
	return (sum(all), len(all))

def sumXorRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x ^ y)
	return (sum(all), len(all))

def sumProdOneDivider(divider, limit):
	count = limit // divider
	return (divider * (count + 1) * count // 2, count)

def get(result, x, limit):
	items = result.items()[:]
	if x not in result:
		result[x] = 0
	result[x] += 1
	if result[x] == 0:
		del result[x]
	for (d, v) in items:
		dx = d * x
		if dx > limit:
			continue
		if dx not in result:
			result[dx] = 0
		result[dx] -= v
		if result[dx] == 0:
			del result[dx]
	return result

def getInterval(start, finish, limit):
	result = {}
	for x in range(start, finish):
		items = list(result.items())[:]
		isdiv = False
		for d in range(start, x):
			if x % d == 0:
				isdiv = True
				break
		if isdiv:
			continue
		result[x] = 1
		for (d, v) in items:
			dx = d * x // gcd(d, x)
			if dx > limit:
				continue
			if dx not in result:
				result[dx] = 0
			result[dx] -= v
			if result[dx] == 0:
				del result[dx]
	return result

def sumProd(A, B):
	all = set()
	s = 0
	l = 0
	for x in range(A, 0, -1):
		process = getInterval(x, A + 1, A * B)
		for (d, v) in process.items():
			(sx0, lx0) = sumProdOneDivider(d, B * (x - 1))
			(sx1, lx1) = sumProdOneDivider(d, B * x)
			s += v * (sx1 - sx0)
			l += v * (lx1 - lx0)
	return (s, l)

def sumXor(A, B):
	if B < 100:
		return sumXorRef(A, B)
	b = B - 100
	s = b * (b + 1) // 2
	l = b + 1
	all = set()
	for x in range(1, A + 1):
		for y in range(b + 1, B + 1):
			xy = x ^ y
			if xy <= b:
				continue
			all.add(xy)
	s += sum(all)
	l += len(all)
	return (s, l)
(A, B) = map(int, input().split())
(prod, nprod) = sumProd(A, B)
(xor, nxor) = sumXor(A, B)
result = prod * nxor * pow(10, len('%d' % B) + 1) + nprod * xor
print(result)


def gcd(x, y):
	while y != 0:
		(x, y) = (y, x % y)
	return x

def sumProdRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x * y)
	return (sum(all), len(all))

def sumXorRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x ^ y)
	return (sum(all), len(all))

def sumProdOneDivider(divider, limit):
	count = limit // divider
	return (divider * (count + 1) * count // 2, count)

def get(result, x, limit):
	items = result.items()[:]
	if x not in result:
		result[x] = 0
	result[x] += 1
	if result[x] == 0:
		del result[x]
	for (d, v) in items:
		dx = d * x
		if dx > limit:
			continue
		if dx not in result:
			result[dx] = 0
		result[dx] -= v
		if result[dx] == 0:
			del result[dx]
	return result

def getInterval(start, finish, limit):
	result = {}
	for x in range(start, finish):
		items = list(result.items())[:]
		isdiv = False
		for d in range(start, x):
			if x % d == 0:
				isdiv = True
				break
		if isdiv:
			continue
		result[x] = 1
		for (d, v) in items:
			dx = d * x // gcd(d, x)
			if dx > limit:
				continue
			if dx not in result:
				result[dx] = 0
			result[dx] -= v
			if result[dx] == 0:
				del result[dx]
	return result

def sumProd(A, B):
	all = set()
	s = 0
	l = 0
	for x in range(A, 0, -1):
		process = getInterval(x, A + 1, A * B)
		for (d, v) in process.items():
			(sx0, lx0) = sumProdOneDivider(d, B * (x - 1))
			(sx1, lx1) = sumProdOneDivider(d, B * x)
			s += v * (sx1 - sx0)
			l += v * (lx1 - lx0)
	return (s, l)

def sumXor(A, B):
	if B < 100:
		return sumXorRef(A, B)
	b = B - 100
	s = b * (b + 1) // 2
	l = b + 1
	all = set()
	for x in range(1, A + 1):
		for y in range(b + 1, B + 1):
			xy = x ^ y
			if xy <= b:
				continue
			all.add(xy)
	s += sum(all)
	l += len(all)
	return (s, l)
(A, B) = map(int, input().split())
(prod, nprod) = sumProd(A, B)
(xor, nxor) = sumXor(A, B)
result = prod * nxor * pow(10, len('%d' % B) + 1) + nprod * xor
print(result)


def gcd(x, y):
	while y != 0:
		(x, y) = (y, x % y)
	return x

def sumProdRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x * y)
	return (sum(all), len(all))

def sumXorRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x ^ y)
	return (sum(all), len(all))

def sumProdOneDivider(divider, limit):
	count = limit // divider
	return (divider * (count + 1) * count // 2, count)

def get(result, x, limit):
	items = result.items()[:]
	if x not in result:
		result[x] = 0
	result[x] += 1
	if result[x] == 0:
		del result[x]
	for (d, v) in items:
		dx = d * x
		if dx > limit:
			continue
		if dx not in result:
			result[dx] = 0
		result[dx] -= v
		if result[dx] == 0:
			del result[dx]
	return result

def getInterval(start, finish, limit):
	result = {}
	for x in range(start, finish):
		items = list(result.items())[:]
		isdiv = False
		for d in range(start, x):
			if x % d == 0:
				isdiv = True
				break
		if isdiv:
			continue
		result[x] = 1
		for (d, v) in items:
			dx = d * x // gcd(d, x)
			if dx > limit:
				continue
			if dx not in result:
				result[dx] = 0
			result[dx] -= v
			if result[dx] == 0:
				del result[dx]
	return result

def sumProd(A, B):
	all = set()
	s = 0
	l = 0
	for x in range(A, 0, -1):
		process = getInterval(x, A + 1, A * B)
		for (d, v) in process.items():
			(sx0, lx0) = sumProdOneDivider(d, B * (x - 1))
			(sx1, lx1) = sumProdOneDivider(d, B * x)
			s += v * (sx1 - sx0)
			l += v * (lx1 - lx0)
	return (s, l)

def sumXor(A, B):
	if B < 100:
		return sumXorRef(A, B)
	b = B - 100
	s = b * (b + 1) // 2
	l = b + 1
	all = set()
	for x in range(1, A + 1):
		for y in range(b + 1, B + 1):
			xy = x ^ y
			if xy <= b:
				continue
			all.add(xy)
	s += sum(all)
	l += len(all)
	return (s, l)
(A, B) = map(int, input().split())
(prod, nprod) = sumProd(A, B)
(xor, nxor) = sumXor(A, B)
result = prod * nxor * pow(10, len('%d' % B) + 1) + nprod * xor
print(result)


def gcd(x, y):
	while y != 0:
		(x, y) = (y, x % y)
	return x

def sumProdRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x * y)
	return (sum(all), len(all))

def sumXorRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x ^ y)
	return (sum(all), len(all))

def sumProdOneDivider(divider, limit):
	count = limit // divider
	return (divider * (count + 1) * count // 2, count)

def get(result, x, limit):
	items = result.items()[:]
	if x not in result:
		result[x] = 0
	result[x] += 1
	if result[x] == 0:
		del result[x]
	for (d, v) in items:
		dx = d * x
		if dx > limit:
			continue
		if dx not in result:
			result[dx] = 0
		result[dx] -= v
		if result[dx] == 0:
			del result[dx]
	return result

def getInterval(start, finish, limit):
	result = {}
	for x in range(start, finish):
		items = list(result.items())[:]
		isdiv = False
		for d in range(start, x):
			if x % d == 0:
				isdiv = True
				break
		if isdiv:
			continue
		result[x] = 1
		for (d, v) in items:
			dx = d * x // gcd(d, x)
			if dx > limit:
				continue
			if dx not in result:
				result[dx] = 0
			result[dx] -= v
			if result[dx] == 0:
				del result[dx]
	return result

def sumProd(A, B):
	all = set()
	s = 0
	l = 0
	for x in range(A, 0, -1):
		process = getInterval(x, A + 1, A * B)
		for (d, v) in process.items():
			(sx0, lx0) = sumProdOneDivider(d, B * (x - 1))
			(sx1, lx1) = sumProdOneDivider(d, B * x)
			s += v * (sx1 - sx0)
			l += v * (lx1 - lx0)
	return (s, l)

def sumXor(A, B):
	if B < 100:
		return sumXorRef(A, B)
	b = B - 100
	s = b * (b + 1) // 2
	l = b + 1
	all = set()
	for x in range(1, A + 1):
		for y in range(b + 1, B + 1):
			xy = x ^ y
			if xy <= b:
				continue
			all.add(xy)
	s += sum(all)
	l += len(all)
	return (s, l)
(A, B) = map(int, input().split())
(prod, nprod) = sumProd(A, B)
(xor, nxor) = sumXor(A, B)
result = prod * nxor * pow(10, len('%d' % B) + 1) + nprod * xor
print(result)


def gcd(x, y):
	while y != 0:
		(x, y) = (y, x % y)
	return x

def sumProdRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x * y)
	return (sum(all), len(all))

def sumXorRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x ^ y)
	return (sum(all), len(all))

def sumProdOneDivider(divider, limit):
	count = limit // divider
	return (divider * (count + 1) * count // 2, count)

def get(result, x, limit):
	items = result.items()[:]
	if x not in result:
		result[x] = 0
	result[x] += 1
	if result[x] == 0:
		del result[x]
	for (d, v) in items:
		dx = d * x
		if dx > limit:
			continue
		if dx not in result:
			result[dx] = 0
		result[dx] -= v
		if result[dx] == 0:
			del result[dx]
	return result

def getInterval(start, finish, limit):
	result = {}
	for x in range(start, finish):
		items = list(result.items())[:]
		isdiv = False
		for d in range(start, x):
			if x % d == 0:
				isdiv = True
				break
		if isdiv:
			continue
		result[x] = 1
		for (d, v) in items:
			dx = d * x // gcd(d, x)
			if dx > limit:
				continue
			if dx not in result:
				result[dx] = 0
			result[dx] -= v
			if result[dx] == 0:
				del result[dx]
	return result

def sumProd(A, B):
	all = set()
	s = 0
	l = 0
	for x in range(A, 0, -1):
		process = getInterval(x, A + 1, A * B)
		for (d, v) in process.items():
			(sx0, lx0) = sumProdOneDivider(d, B * (x - 1))
			(sx1, lx1) = sumProdOneDivider(d, B * x)
			s += v * (sx1 - sx0)
			l += v * (lx1 - lx0)
	return (s, l)

def sumXor(A, B):
	if B < 100:
		return sumXorRef(A, B)
	b = B - 100
	s = b * (b + 1) // 2
	l = b + 1
	all = set()
	for x in range(1, A + 1):
		for y in range(b + 1, B + 1):
			xy = x ^ y
			if xy <= b:
				continue
			all.add(xy)
	s += sum(all)
	l += len(all)
	return (s, l)
(A, B) = map(int, input().split())
(prod, nprod) = sumProd(A, B)
(xor, nxor) = sumXor(A, B)
result = prod * nxor * pow(10, len('%d' % B) + 1) + nprod * xor
print(result)


def gcd(x, y):
	while y != 0:
		(x, y) = (y, x % y)
	return x

def sumProdRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x * y)
	return (sum(all), len(all))

def sumXorRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x ^ y)
	return (sum(all), len(all))

def sumProdOneDivider(divider, limit):
	count = limit // divider
	return (divider * (count + 1) * count // 2, count)

def get(result, x, limit):
	items = result.items()[:]
	if x not in result:
		result[x] = 0
	result[x] += 1
	if result[x] == 0:
		del result[x]
	for (d, v) in items:
		dx = d * x
		if dx > limit:
			continue
		if dx not in result:
			result[dx] = 0
		result[dx] -= v
		if result[dx] == 0:
			del result[dx]
	return result

def getInterval(start, finish, limit):
	result = {}
	for x in range(start, finish):
		items = list(result.items())[:]
		isdiv = False
		for d in range(start, x):
			if x % d == 0:
				isdiv = True
				break
		if isdiv:
			continue
		result[x] = 1
		for (d, v) in items:
			dx = d * x // gcd(d, x)
			if dx > limit:
				continue
			if dx not in result:
				result[dx] = 0
			result[dx] -= v
			if result[dx] == 0:
				del result[dx]
	return result

def sumProd(A, B):
	all = set()
	s = 0
	l = 0
	for x in range(A, 0, -1):
		process = getInterval(x, A + 1, A * B)
		for (d, v) in process.items():
			(sx0, lx0) = sumProdOneDivider(d, B * (x - 1))
			(sx1, lx1) = sumProdOneDivider(d, B * x)
			s += v * (sx1 - sx0)
			l += v * (lx1 - lx0)
	return (s, l)

def sumXor(A, B):
	if B < 100:
		return sumXorRef(A, B)
	b = B - 100
	s = b * (b + 1) // 2
	l = b + 1
	all = set()
	for x in range(1, A + 1):
		for y in range(b + 1, B + 1):
			xy = x ^ y
			if xy <= b:
				continue
			all.add(xy)
	s += sum(all)
	l += len(all)
	return (s, l)
(A, B) = map(int, input().split())
(prod, nprod) = sumProd(A, B)
(xor, nxor) = sumXor(A, B)
result = prod * nxor * pow(10, len('%d' % B) + 1) + nprod * xor
print(result)


def gcd(x, y):
	while y != 0:
		(x, y) = (y, x % y)
	return x

def sumProdRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x * y)
	return (sum(all), len(all))

def sumXorRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x ^ y)
	return (sum(all), len(all))

def sumProdOneDivider(divider, limit):
	count = limit // divider
	return (divider * (count + 1) * count // 2, count)

def get(result, x, limit):
	items = result.items()[:]
	if x not in result:
		result[x] = 0
	result[x] += 1
	if result[x] == 0:
		del result[x]
	for (d, v) in items:
		dx = d * x
		if dx > limit:
			continue
		if dx not in result:
			result[dx] = 0
		result[dx] -= v
		if result[dx] == 0:
			del result[dx]
	return result

def getInterval(start, finish, limit):
	result = {}
	for x in range(start, finish):
		items = list(result.items())[:]
		isdiv = False
		for d in range(start, x):
			if x % d == 0:
				isdiv = True
				break
		if isdiv:
			continue
		result[x] = 1
		for (d, v) in items:
			dx = d * x // gcd(d, x)
			if dx > limit:
				continue
			if dx not in result:
				result[dx] = 0
			result[dx] -= v
			if result[dx] == 0:
				del result[dx]
	return result

def sumProd(A, B):
	all = set()
	s = 0
	l = 0
	for x in range(A, 0, -1):
		process = getInterval(x, A + 1, A * B)
		for (d, v) in process.items():
			(sx0, lx0) = sumProdOneDivider(d, B * (x - 1))
			(sx1, lx1) = sumProdOneDivider(d, B * x)
			s += v * (sx1 - sx0)
			l += v * (lx1 - lx0)
	return (s, l)

def sumXor(A, B):
	if B < 100:
		return sumXorRef(A, B)
	b = B - 100
	s = b * (b + 1) // 2
	l = b + 1
	all = set()
	for x in range(1, A + 1):
		for y in range(b + 1, B + 1):
			xy = x ^ y
			if xy <= b:
				continue
			all.add(xy)
	s += sum(all)
	l += len(all)
	return (s, l)
(A, B) = map(int, input().split())
(prod, nprod) = sumProd(A, B)
(xor, nxor) = sumXor(A, B)
result = prod * nxor * pow(10, len('%d' % B) + 1) + nprod * xor
print(result)


def gcd(x, y):
	while y != 0:
		(x, y) = (y, x % y)
	return x

def sumProdRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x * y)
	return (sum(all), len(all))

def sumXorRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x ^ y)
	return (sum(all), len(all))

def sumProdOneDivider(divider, limit):
	count = limit // divider
	return (divider * (count + 1) * count // 2, count)

def get(result, x, limit):
	items = result.items()[:]
	if x not in result:
		result[x] = 0
	result[x] += 1
	if result[x] == 0:
		del result[x]
	for (d, v) in items:
		dx = d * x
		if dx > limit:
			continue
		if dx not in result:
			result[dx] = 0
		result[dx] -= v
		if result[dx] == 0:
			del result[dx]
	return result

def getInterval(start, finish, limit):
	result = {}
	for x in range(start, finish):
		items = list(result.items())[:]
		isdiv = False
		for d in range(start, x):
			if x % d == 0:
				isdiv = True
				break
		if isdiv:
			continue
		result[x] = 1
		for (d, v) in items:
			dx = d * x // gcd(d, x)
			if dx > limit:
				continue
			if dx not in result:
				result[dx] = 0
			result[dx] -= v
			if result[dx] == 0:
				del result[dx]
	return result

def sumProd(A, B):
	all = set()
	s = 0
	l = 0
	for x in range(A, 0, -1):
		process = getInterval(x, A + 1, A * B)
		for (d, v) in process.items():
			(sx0, lx0) = sumProdOneDivider(d, B * (x - 1))
			(sx1, lx1) = sumProdOneDivider(d, B * x)
			s += v * (sx1 - sx0)
			l += v * (lx1 - lx0)
	return (s, l)

def sumXor(A, B):
	if B < 100:
		return sumXorRef(A, B)
	b = B - 100
	s = b * (b + 1) // 2
	l = b + 1
	all = set()
	for x in range(1, A + 1):
		for y in range(b + 1, B + 1):
			xy = x ^ y
			if xy <= b:
				continue
			all.add(xy)
	s += sum(all)
	l += len(all)
	return (s, l)
(A, B) = map(int, input().split())
(prod, nprod) = sumProd(A, B)
(xor, nxor) = sumXor(A, B)
result = prod * nxor * pow(10, len('%d' % B) + 1) + nprod * xor
print(result)


def gcd(x, y):
	while y != 0:
		(x, y) = (y, x % y)
	return x

def sumProdRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x * y)
	return (sum(all), len(all))

def sumXorRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x ^ y)
	return (sum(all), len(all))

def sumProdOneDivider(divider, limit):
	count = limit // divider
	return (divider * (count + 1) * count // 2, count)

def get(result, x, limit):
	items = result.items()[:]
	if x not in result:
		result[x] = 0
	result[x] += 1
	if result[x] == 0:
		del result[x]
	for (d, v) in items:
		dx = d * x
		if dx > limit:
			continue
		if dx not in result:
			result[dx] = 0
		result[dx] -= v
		if result[dx] == 0:
			del result[dx]
	return result

def getInterval(start, finish, limit):
	result = {}
	for x in range(start, finish):
		items = list(result.items())[:]
		isdiv = False
		for d in range(start, x):
			if x % d == 0:
				isdiv = True
				break
		if isdiv:
			continue
		result[x] = 1
		for (d, v) in items:
			dx = d * x // gcd(d, x)
			if dx > limit:
				continue
			if dx not in result:
				result[dx] = 0
			result[dx] -= v
			if result[dx] == 0:
				del result[dx]
	return result

def sumProd(A, B):
	all = set()
	s = 0
	l = 0
	for x in range(A, 0, -1):
		process = getInterval(x, A + 1, A * B)
		for (d, v) in process.items():
			(sx0, lx0) = sumProdOneDivider(d, B * (x - 1))
			(sx1, lx1) = sumProdOneDivider(d, B * x)
			s += v * (sx1 - sx0)
			l += v * (lx1 - lx0)
	return (s, l)

def sumXor(A, B):
	if B < 100:
		return sumXorRef(A, B)
	b = B - 100
	s = b * (b + 1) // 2
	l = b + 1
	all = set()
	for x in range(1, A + 1):
		for y in range(b + 1, B + 1):
			xy = x ^ y
			if xy <= b:
				continue
			all.add(xy)
	s += sum(all)
	l += len(all)
	return (s, l)
(A, B) = map(int, input().split())
(prod, nprod) = sumProd(A, B)
(xor, nxor) = sumXor(A, B)
result = prod * nxor * pow(10, len('%d' % B) + 1) + nprod * xor
print(result)


def gcd(x, y):
	while y != 0:
		(x, y) = (y, x % y)
	return x

def sumProdRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x * y)
	return (sum(all), len(all))

def sumXorRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x ^ y)
	return (sum(all), len(all))

def sumProdOneDivider(divider, limit):
	count = limit // divider
	return (divider * (count + 1) * count // 2, count)

def get(result, x, limit):
	items = result.items()[:]
	if x not in result:
		result[x] = 0
	result[x] += 1
	if result[x] == 0:
		del result[x]
	for (d, v) in items:
		dx = d * x
		if dx > limit:
			continue
		if dx not in result:
			result[dx] = 0
		result[dx] -= v
		if result[dx] == 0:
			del result[dx]
	return result

def getInterval(start, finish, limit):
	result = {}
	for x in range(start, finish):
		items = list(result.items())[:]
		isdiv = False
		for d in range(start, x):
			if x % d == 0:
				isdiv = True
				break
		if isdiv:
			continue
		result[x] = 1
		for (d, v) in items:
			dx = d * x // gcd(d, x)
			if dx > limit:
				continue
			if dx not in result:
				result[dx] = 0
			result[dx] -= v
			if result[dx] == 0:
				del result[dx]
	return result

def sumProd(A, B):
	all = set()
	s = 0
	l = 0
	for x in range(A, 0, -1):
		process = getInterval(x, A + 1, A * B)
		for (d, v) in process.items():
			(sx0, lx0) = sumProdOneDivider(d, B * (x - 1))
			(sx1, lx1) = sumProdOneDivider(d, B * x)
			s += v * (sx1 - sx0)
			l += v * (lx1 - lx0)
	return (s, l)

def sumXor(A, B):
	if B < 100:
		return sumXorRef(A, B)
	b = B - 100
	s = b * (b + 1) // 2
	l = b + 1
	all = set()
	for x in range(1, A + 1):
		for y in range(b + 1, B + 1):
			xy = x ^ y
			if xy <= b:
				continue
			all.add(xy)
	s += sum(all)
	l += len(all)
	return (s, l)
(A, B) = map(int, input().split())
(prod, nprod) = sumProd(A, B)
(xor, nxor) = sumXor(A, B)
result = prod * nxor * pow(10, len('%d' % B) + 1) + nprod * xor
print(result)


def gcd(x, y):
	while y != 0:
		(x, y) = (y, x % y)
	return x

def sumProdRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x * y)
	return (sum(all), len(all))

def sumXorRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x ^ y)
	return (sum(all), len(all))

def sumProdOneDivider(divider, limit):
	count = limit // divider
	return (divider * (count + 1) * count // 2, count)

def get(result, x, limit):
	items = result.items()[:]
	if x not in result:
		result[x] = 0
	result[x] += 1
	if result[x] == 0:
		del result[x]
	for (d, v) in items:
		dx = d * x
		if dx > limit:
			continue
		if dx not in result:
			result[dx] = 0
		result[dx] -= v
		if result[dx] == 0:
			del result[dx]
	return result

def getInterval(start, finish, limit):
	result = {}
	for x in range(start, finish):
		items = list(result.items())[:]
		isdiv = False
		for d in range(start, x):
			if x % d == 0:
				isdiv = True
				break
		if isdiv:
			continue
		result[x] = 1
		for (d, v) in items:
			dx = d * x // gcd(d, x)
			if dx > limit:
				continue
			if dx not in result:
				result[dx] = 0
			result[dx] -= v
			if result[dx] == 0:
				del result[dx]
	return result

def sumProd(A, B):
	all = set()
	s = 0
	l = 0
	for x in range(A, 0, -1):
		process = getInterval(x, A + 1, A * B)
		for (d, v) in process.items():
			(sx0, lx0) = sumProdOneDivider(d, B * (x - 1))
			(sx1, lx1) = sumProdOneDivider(d, B * x)
			s += v * (sx1 - sx0)
			l += v * (lx1 - lx0)
	return (s, l)

def sumXor(A, B):
	if B < 100:
		return sumXorRef(A, B)
	b = B - 100
	s = b * (b + 1) // 2
	l = b + 1
	all = set()
	for x in range(1, A + 1):
		for y in range(b + 1, B + 1):
			xy = x ^ y
			if xy <= b:
				continue
			all.add(xy)
	s += sum(all)
	l += len(all)
	return (s, l)
(A, B) = map(int, input().split())
(prod, nprod) = sumProd(A, B)
(xor, nxor) = sumXor(A, B)
result = prod * nxor * pow(10, len('%d' % B) + 1) + nprod * xor
print(result)


def gcd(x, y):
	while y != 0:
		(x, y) = (y, x % y)
	return x

def sumProdRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x * y)
	return (sum(all), len(all))

def sumXorRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x ^ y)
	return (sum(all), len(all))

def sumProdOneDivider(divider, limit):
	count = limit // divider
	return (divider * (count + 1) * count // 2, count)

def get(result, x, limit):
	items = result.items()[:]
	if x not in result:
		result[x] = 0
	result[x] += 1
	if result[x] == 0:
		del result[x]
	for (d, v) in items:
		dx = d * x
		if dx > limit:
			continue
		if dx not in result:
			result[dx] = 0
		result[dx] -= v
		if result[dx] == 0:
			del result[dx]
	return result

def getInterval(start, finish, limit):
	result = {}
	for x in range(start, finish):
		items = list(result.items())[:]
		isdiv = False
		for d in range(start, x):
			if x % d == 0:
				isdiv = True
				break
		if isdiv:
			continue
		result[x] = 1
		for (d, v) in items:
			dx = d * x // gcd(d, x)
			if dx > limit:
				continue
			if dx not in result:
				result[dx] = 0
			result[dx] -= v
			if result[dx] == 0:
				del result[dx]
	return result

def sumProd(A, B):
	all = set()
	s = 0
	l = 0
	for x in range(A, 0, -1):
		process = getInterval(x, A + 1, A * B)
		for (d, v) in process.items():
			(sx0, lx0) = sumProdOneDivider(d, B * (x - 1))
			(sx1, lx1) = sumProdOneDivider(d, B * x)
			s += v * (sx1 - sx0)
			l += v * (lx1 - lx0)
	return (s, l)

def sumXor(A, B):
	if B < 100:
		return sumXorRef(A, B)
	b = B - 100
	s = b * (b + 1) // 2
	l = b + 1
	all = set()
	for x in range(1, A + 1):
		for y in range(b + 1, B + 1):
			xy = x ^ y
			if xy <= b:
				continue
			all.add(xy)
	s += sum(all)
	l += len(all)
	return (s, l)
(A, B) = map(int, input().split())
(prod, nprod) = sumProd(A, B)
(xor, nxor) = sumXor(A, B)
result = prod * nxor * pow(10, len('%d' % B) + 1) + nprod * xor
print(result)


def gcd(x, y):
	while y != 0:
		(x, y) = (y, x % y)
	return x

def sumProdRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x * y)
	return (sum(all), len(all))

def sumXorRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x ^ y)
	return (sum(all), len(all))

def sumProdOneDivider(divider, limit):
	count = limit // divider
	return (divider * (count + 1) * count // 2, count)

def get(result, x, limit):
	items = result.items()[:]
	if x not in result:
		result[x] = 0
	result[x] += 1
	if result[x] == 0:
		del result[x]
	for (d, v) in items:
		dx = d * x
		if dx > limit:
			continue
		if dx not in result:
			result[dx] = 0
		result[dx] -= v
		if result[dx] == 0:
			del result[dx]
	return result

def getInterval(start, finish, limit):
	result = {}
	for x in range(start, finish):
		items = list(result.items())[:]
		isdiv = False
		for d in range(start, x):
			if x % d == 0:
				isdiv = True
				break
		if isdiv:
			continue
		result[x] = 1
		for (d, v) in items:
			dx = d * x // gcd(d, x)
			if dx > limit:
				continue
			if dx not in result:
				result[dx] = 0
			result[dx] -= v
			if result[dx] == 0:
				del result[dx]
	return result

def sumProd(A, B):
	all = set()
	s = 0
	l = 0
	for x in range(A, 0, -1):
		process = getInterval(x, A + 1, A * B)
		for (d, v) in process.items():
			(sx0, lx0) = sumProdOneDivider(d, B * (x - 1))
			(sx1, lx1) = sumProdOneDivider(d, B * x)
			s += v * (sx1 - sx0)
			l += v * (lx1 - lx0)
	return (s, l)

def sumXor(A, B):
	if B < 100:
		return sumXorRef(A, B)
	b = B - 100
	s = b * (b + 1) // 2
	l = b + 1
	all = set()
	for x in range(1, A + 1):
		for y in range(b + 1, B + 1):
			xy = x ^ y
			if xy <= b:
				continue
			all.add(xy)
	s += sum(all)
	l += len(all)
	return (s, l)
(A, B) = map(int, input().split())
(prod, nprod) = sumProd(A, B)
(xor, nxor) = sumXor(A, B)
result = prod * nxor * pow(10, len('%d' % B) + 1) + nprod * xor
print(result)


def gcd(x, y):
	while y != 0:
		(x, y) = (y, x % y)
	return x

def sumProdRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x * y)
	return (sum(all), len(all))

def sumXorRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x ^ y)
	return (sum(all), len(all))

def sumProdOneDivider(divider, limit):
	count = limit // divider
	return (divider * (count + 1) * count // 2, count)

def get(result, x, limit):
	items = result.items()[:]
	if x not in result:
		result[x] = 0
	result[x] += 1
	if result[x] == 0:
		del result[x]
	for (d, v) in items:
		dx = d * x
		if dx > limit:
			continue
		if dx not in result:
			result[dx] = 0
		result[dx] -= v
		if result[dx] == 0:
			del result[dx]
	return result

def getInterval(start, finish, limit):
	result = {}
	for x in range(start, finish):
		items = list(result.items())[:]
		isdiv = False
		for d in range(start, x):
			if x % d == 0:
				isdiv = True
				break
		if isdiv:
			continue
		result[x] = 1
		for (d, v) in items:
			dx = d * x // gcd(d, x)
			if dx > limit:
				continue
			if dx not in result:
				result[dx] = 0
			result[dx] -= v
			if result[dx] == 0:
				del result[dx]
	return result

def sumProd(A, B):
	all = set()
	s = 0
	l = 0
	for x in range(A, 0, -1):
		process = getInterval(x, A + 1, A * B)
		for (d, v) in process.items():
			(sx0, lx0) = sumProdOneDivider(d, B * (x - 1))
			(sx1, lx1) = sumProdOneDivider(d, B * x)
			s += v * (sx1 - sx0)
			l += v * (lx1 - lx0)
	return (s, l)

def sumXor(A, B):
	if B < 100:
		return sumXorRef(A, B)
	b = B - 100
	s = b * (b + 1) // 2
	l = b + 1
	all = set()
	for x in range(1, A + 1):
		for y in range(b + 1, B + 1):
			xy = x ^ y
			if xy <= b:
				continue
			all.add(xy)
	s += sum(all)
	l += len(all)
	return (s, l)
(A, B) = map(int, input().split())
(prod, nprod) = sumProd(A, B)
(xor, nxor) = sumXor(A, B)
result = prod * nxor * pow(10, len('%d' % B) + 1) + nprod * xor
print(result)


import math

def lcm(a, b):
	return a * b // math.gcd(a, b)
[a, b] = list(map(int, input().strip().split(' ')))
curr = b
leftmult = 10
while curr > 0:
	curr //= 10
	leftmult *= 10
[a, b] = sorted([a, b])
if a == 1 and b == 1:
	print(0)
else:
	themax = a + b
	for dig in range(30, 0, -1):
		if (a >> dig) % 2 == 1 and (b >> dig) % 2 == 1:
			themax = ((a >> dig) + (b >> dig) << dig) - 1
			break
	pow2 = 1
	curr = a - 1
	while curr > 0:
		pow2 *= 2
		curr //= 2
	exclude = 0
	rightnum = themax + 1
	if b % pow2 == 0:
		exclude = b
		rightnum -= 1
	if a == 1 and b % 2 == 0:
		exclude += 1
		rightnum -= 1
	righttot = themax * (themax + 1) // 2
	righttot -= exclude
	repqueue = dict()
	repqueue[31, 1] = -1
	for i in range(1, a + 1):
		addrep = dict()
		for (low, thelcm) in repqueue.keys():
			if repqueue[low, thelcm] != 0:
				try:
					addrep[min(low, i), lcm(thelcm, i)] -= repqueue[low, thelcm]
				except:
					addrep[min(low, i), lcm(thelcm, i)] = -repqueue[low, thelcm]
		for (x, y) in addrep:
			try:
				repqueue[x, y] += addrep[x, y]
				if repqueue[x, y] == 0:
					repqueue.pop((x, y))
			except:
				repqueue[x, y] = addrep[x, y]
	repqueue.pop((31, 1))
	leftnum = 0
	lefttot = 0
	for (low, thelcm) in repqueue.keys():
		num = b * low // thelcm
		leftnum += num * repqueue[low, thelcm]
		lefttot += thelcm * (num * (num + 1) // 2) * repqueue[low, thelcm]
	print(lefttot * rightnum * leftmult + righttot * leftnum)


def gcd(x, y):
	while y != 0:
		(x, y) = (y, x % y)
	return x

def sumProdRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x * y)
	return (sum(all), len(all))

def sumXorRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x ^ y)
	return (sum(all), len(all))

def sumProdOneDivider(divider, limit):
	count = limit // divider
	return (divider * (count + 1) * count // 2, count)

def get(result, x, limit):
	items = result.items()[:]
	if x not in result:
		result[x] = 0
	result[x] += 1
	if result[x] == 0:
		del result[x]
	for (d, v) in items:
		dx = d * x
		if dx > limit:
			continue
		if dx not in result:
			result[dx] = 0
		result[dx] -= v
		if result[dx] == 0:
			del result[dx]
	return result

def getInterval(start, finish, limit):
	result = {}
	for x in range(start, finish):
		items = list(result.items())[:]
		isdiv = False
		for d in range(start, x):
			if x % d == 0:
				isdiv = True
				break
		if isdiv:
			continue
		result[x] = 1
		for (d, v) in items:
			dx = d * x // gcd(d, x)
			if dx > limit:
				continue
			if dx not in result:
				result[dx] = 0
			result[dx] -= v
			if result[dx] == 0:
				del result[dx]
	return result

def sumProd(A, B):
	all = set()
	s = 0
	l = 0
	for x in range(A, 0, -1):
		process = getInterval(x, A + 1, A * B)
		for (d, v) in process.items():
			(sx0, lx0) = sumProdOneDivider(d, B * (x - 1))
			(sx1, lx1) = sumProdOneDivider(d, B * x)
			s += v * (sx1 - sx0)
			l += v * (lx1 - lx0)
	return (s, l)

def sumXor(A, B):
	if B < 100:
		return sumXorRef(A, B)
	b = B - 100
	s = b * (b + 1) // 2
	l = b + 1
	all = set()
	for x in range(1, A + 1):
		for y in range(b + 1, B + 1):
			xy = x ^ y
			if xy <= b:
				continue
			all.add(xy)
	s += sum(all)
	l += len(all)
	return (s, l)
(A, B) = map(int, input().split())
(prod, nprod) = sumProd(A, B)
(xor, nxor) = sumXor(A, B)
result = prod * nxor * pow(10, len('%d' % B) + 1) + nprod * xor
print(result)


def gcd(x, y):
	while y != 0:
		(x, y) = (y, x % y)
	return x

def sumProdRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x * y)
	return (sum(all), len(all))

def sumXorRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x ^ y)
	return (sum(all), len(all))

def sumProdOneDivider(divider, limit):
	count = limit // divider
	return (divider * (count + 1) * count // 2, count)

def get(result, x, limit):
	items = result.items()[:]
	if x not in result:
		result[x] = 0
	result[x] += 1
	if result[x] == 0:
		del result[x]
	for (d, v) in items:
		dx = d * x
		if dx > limit:
			continue
		if dx not in result:
			result[dx] = 0
		result[dx] -= v
		if result[dx] == 0:
			del result[dx]
	return result

def getInterval(start, finish, limit):
	result = {}
	for x in range(start, finish):
		items = list(result.items())[:]
		isdiv = False
		for d in range(start, x):
			if x % d == 0:
				isdiv = True
				break
		if isdiv:
			continue
		result[x] = 1
		for (d, v) in items:
			dx = d * x // gcd(d, x)
			if dx > limit:
				continue
			if dx not in result:
				result[dx] = 0
			result[dx] -= v
			if result[dx] == 0:
				del result[dx]
	return result

def sumProd(A, B):
	all = set()
	s = 0
	l = 0
	for x in range(A, 0, -1):
		process = getInterval(x, A + 1, A * B)
		for (d, v) in process.items():
			(sx0, lx0) = sumProdOneDivider(d, B * (x - 1))
			(sx1, lx1) = sumProdOneDivider(d, B * x)
			s += v * (sx1 - sx0)
			l += v * (lx1 - lx0)
	return (s, l)

def sumXor(A, B):
	if B < 100:
		return sumXorRef(A, B)
	b = B - 100
	s = b * (b + 1) // 2
	l = b + 1
	all = set()
	for x in range(1, A + 1):
		for y in range(b + 1, B + 1):
			xy = x ^ y
			if xy <= b:
				continue
			all.add(xy)
	s += sum(all)
	l += len(all)
	return (s, l)
(A, B) = map(int, input().split())
(prod, nprod) = sumProd(A, B)
(xor, nxor) = sumXor(A, B)
result = prod * nxor * pow(10, len('%d' % B) + 1) + nprod * xor
print(result)


def gcd(x, y):
	while y != 0:
		(x, y) = (y, x % y)
	return x

def sumProdRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x * y)
	return (sum(all), len(all))

def sumXorRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x ^ y)
	return (sum(all), len(all))

def sumProdOneDivider(divider, limit):
	count = limit // divider
	return (divider * (count + 1) * count // 2, count)

def get(result, x, limit):
	items = result.items()[:]
	if x not in result:
		result[x] = 0
	result[x] += 1
	if result[x] == 0:
		del result[x]
	for (d, v) in items:
		dx = d * x
		if dx > limit:
			continue
		if dx not in result:
			result[dx] = 0
		result[dx] -= v
		if result[dx] == 0:
			del result[dx]
	return result

def getInterval(start, finish, limit):
	result = {}
	for x in range(start, finish):
		items = list(result.items())[:]
		isdiv = False
		for d in range(start, x):
			if x % d == 0:
				isdiv = True
				break
		if isdiv:
			continue
		result[x] = 1
		for (d, v) in items:
			dx = d * x // gcd(d, x)
			if dx > limit:
				continue
			if dx not in result:
				result[dx] = 0
			result[dx] -= v
			if result[dx] == 0:
				del result[dx]
	return result

def sumProd(A, B):
	all = set()
	s = 0
	l = 0
	for x in range(A, 0, -1):
		process = getInterval(x, A + 1, A * B)
		for (d, v) in process.items():
			(sx0, lx0) = sumProdOneDivider(d, B * (x - 1))
			(sx1, lx1) = sumProdOneDivider(d, B * x)
			s += v * (sx1 - sx0)
			l += v * (lx1 - lx0)
	return (s, l)

def sumXor(A, B):
	if B < 100:
		return sumXorRef(A, B)
	b = B - 100
	s = b * (b + 1) // 2
	l = b + 1
	all = set()
	for x in range(1, A + 1):
		for y in range(b + 1, B + 1):
			xy = x ^ y
			if xy <= b:
				continue
			all.add(xy)
	s += sum(all)
	l += len(all)
	return (s, l)
(A, B) = map(int, input().split())
(prod, nprod) = sumProd(A, B)
(xor, nxor) = sumXor(A, B)
result = prod * nxor * pow(10, len('%d' % B) + 1) + nprod * xor
print(result)


def gcd(x, y):
	while y != 0:
		(x, y) = (y, x % y)
	return x

def sumProdRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x * y)
	return (sum(all), len(all))

def sumXorRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x ^ y)
	return (sum(all), len(all))

def sumProdOneDivider(divider, limit):
	count = limit // divider
	return (divider * (count + 1) * count // 2, count)

def get(result, x, limit):
	items = result.items()[:]
	if x not in result:
		result[x] = 0
	result[x] += 1
	if result[x] == 0:
		del result[x]
	for (d, v) in items:
		dx = d * x
		if dx > limit:
			continue
		if dx not in result:
			result[dx] = 0
		result[dx] -= v
		if result[dx] == 0:
			del result[dx]
	return result

def getInterval(start, finish, limit):
	result = {}
	for x in range(start, finish):
		items = list(result.items())[:]
		isdiv = False
		for d in range(start, x):
			if x % d == 0:
				isdiv = True
				break
		if isdiv:
			continue
		result[x] = 1
		for (d, v) in items:
			dx = d * x // gcd(d, x)
			if dx > limit:
				continue
			if dx not in result:
				result[dx] = 0
			result[dx] -= v
			if result[dx] == 0:
				del result[dx]
	return result

def sumProd(A, B):
	all = set()
	s = 0
	l = 0
	for x in range(A, 0, -1):
		process = getInterval(x, A + 1, A * B)
		for (d, v) in process.items():
			(sx0, lx0) = sumProdOneDivider(d, B * (x - 1))
			(sx1, lx1) = sumProdOneDivider(d, B * x)
			s += v * (sx1 - sx0)
			l += v * (lx1 - lx0)
	return (s, l)

def sumXor(A, B):
	if B < 100:
		return sumXorRef(A, B)
	b = B - 100
	s = b * (b + 1) // 2
	l = b + 1
	all = set()
	for x in range(1, A + 1):
		for y in range(b + 1, B + 1):
			xy = x ^ y
			if xy <= b:
				continue
			all.add(xy)
	s += sum(all)
	l += len(all)
	return (s, l)
(A, B) = map(int, input().split())
(prod, nprod) = sumProd(A, B)
(xor, nxor) = sumXor(A, B)
result = prod * nxor * pow(10, len('%d' % B) + 1) + nprod * xor
print(result)


def gcd(x, y):
	while y != 0:
		(x, y) = (y, x % y)
	return x

def sumProdRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x * y)
	return (sum(all), len(all))

def sumXorRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x ^ y)
	return (sum(all), len(all))

def sumProdOneDivider(divider, limit):
	count = limit // divider
	return (divider * (count + 1) * count // 2, count)

def get(result, x, limit):
	items = result.items()[:]
	if x not in result:
		result[x] = 0
	result[x] += 1
	if result[x] == 0:
		del result[x]
	for (d, v) in items:
		dx = d * x
		if dx > limit:
			continue
		if dx not in result:
			result[dx] = 0
		result[dx] -= v
		if result[dx] == 0:
			del result[dx]
	return result

def getInterval(start, finish, limit):
	result = {}
	for x in range(start, finish):
		items = list(result.items())[:]
		isdiv = False
		for d in range(start, x):
			if x % d == 0:
				isdiv = True
				break
		if isdiv:
			continue
		result[x] = 1
		for (d, v) in items:
			dx = d * x // gcd(d, x)
			if dx > limit:
				continue
			if dx not in result:
				result[dx] = 0
			result[dx] -= v
			if result[dx] == 0:
				del result[dx]
	return result

def sumProd(A, B):
	all = set()
	s = 0
	l = 0
	for x in range(A, 0, -1):
		process = getInterval(x, A + 1, A * B)
		for (d, v) in process.items():
			(sx0, lx0) = sumProdOneDivider(d, B * (x - 1))
			(sx1, lx1) = sumProdOneDivider(d, B * x)
			s += v * (sx1 - sx0)
			l += v * (lx1 - lx0)
	return (s, l)

def sumXor(A, B):
	if B < 100:
		return sumXorRef(A, B)
	b = B - 100
	s = b * (b + 1) // 2
	l = b + 1
	all = set()
	for x in range(1, A + 1):
		for y in range(b + 1, B + 1):
			xy = x ^ y
			if xy <= b:
				continue
			all.add(xy)
	s += sum(all)
	l += len(all)
	return (s, l)
(A, B) = map(int, input().split())
(prod, nprod) = sumProd(A, B)
(xor, nxor) = sumXor(A, B)
result = prod * nxor * pow(10, len('%d' % B) + 1) + nprod * xor
print(result)


def gcd(x, y):
	while y != 0:
		(x, y) = (y, x % y)
	return x

def sumProdRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x * y)
	return (sum(all), len(all))

def sumXorRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x ^ y)
	return (sum(all), len(all))

def sumProdOneDivider(divider, limit):
	count = limit // divider
	return (divider * (count + 1) * count // 2, count)

def get(result, x, limit):
	items = result.items()[:]
	if x not in result:
		result[x] = 0
	result[x] += 1
	if result[x] == 0:
		del result[x]
	for (d, v) in items:
		dx = d * x
		if dx > limit:
			continue
		if dx not in result:
			result[dx] = 0
		result[dx] -= v
		if result[dx] == 0:
			del result[dx]
	return result

def getInterval(start, finish, limit):
	result = {}
	for x in range(start, finish):
		items = list(result.items())[:]
		isdiv = False
		for d in range(start, x):
			if x % d == 0:
				isdiv = True
				break
		if isdiv:
			continue
		result[x] = 1
		for (d, v) in items:
			dx = d * x // gcd(d, x)
			if dx > limit:
				continue
			if dx not in result:
				result[dx] = 0
			result[dx] -= v
			if result[dx] == 0:
				del result[dx]
	return result

def sumProd(A, B):
	all = set()
	s = 0
	l = 0
	for x in range(A, 0, -1):
		process = getInterval(x, A + 1, A * B)
		for (d, v) in process.items():
			(sx0, lx0) = sumProdOneDivider(d, B * (x - 1))
			(sx1, lx1) = sumProdOneDivider(d, B * x)
			s += v * (sx1 - sx0)
			l += v * (lx1 - lx0)
	return (s, l)

def sumXor(A, B):
	if B < 100:
		return sumXorRef(A, B)
	b = B - 100
	s = b * (b + 1) // 2
	l = b + 1
	all = set()
	for x in range(1, A + 1):
		for y in range(b + 1, B + 1):
			xy = x ^ y
			if xy <= b:
				continue
			all.add(xy)
	s += sum(all)
	l += len(all)
	return (s, l)
(A, B) = map(int, input().split())
(prod, nprod) = sumProd(A, B)
(xor, nxor) = sumXor(A, B)
result = prod * nxor * pow(10, len('%d' % B) + 1) + nprod * xor
print(result)


def gcd(x, y):
	while y != 0:
		(x, y) = (y, x % y)
	return x

def sumProdRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x * y)
	return (sum(all), len(all))

def sumXorRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x ^ y)
	return (sum(all), len(all))

def sumProdOneDivider(divider, limit):
	count = limit // divider
	return (divider * (count + 1) * count // 2, count)

def get(result, x, limit):
	items = result.items()[:]
	if x not in result:
		result[x] = 0
	result[x] += 1
	if result[x] == 0:
		del result[x]
	for (d, v) in items:
		dx = d * x
		if dx > limit:
			continue
		if dx not in result:
			result[dx] = 0
		result[dx] -= v
		if result[dx] == 0:
			del result[dx]
	return result

def getInterval(start, finish, limit):
	result = {}
	for x in range(start, finish):
		items = list(result.items())[:]
		isdiv = False
		for d in range(start, x):
			if x % d == 0:
				isdiv = True
				break
		if isdiv:
			continue
		result[x] = 1
		for (d, v) in items:
			dx = d * x // gcd(d, x)
			if dx > limit:
				continue
			if dx not in result:
				result[dx] = 0
			result[dx] -= v
			if result[dx] == 0:
				del result[dx]
	return result

def sumProd(A, B):
	all = set()
	s = 0
	l = 0
	for x in range(A, 0, -1):
		process = getInterval(x, A + 1, A * B)
		for (d, v) in process.items():
			(sx0, lx0) = sumProdOneDivider(d, B * (x - 1))
			(sx1, lx1) = sumProdOneDivider(d, B * x)
			s += v * (sx1 - sx0)
			l += v * (lx1 - lx0)
	return (s, l)

def sumXor(A, B):
	if B < 100:
		return sumXorRef(A, B)
	b = B - 100
	s = b * (b + 1) // 2
	l = b + 1
	all = set()
	for x in range(1, A + 1):
		for y in range(b + 1, B + 1):
			xy = x ^ y
			if xy <= b:
				continue
			all.add(xy)
	s += sum(all)
	l += len(all)
	return (s, l)
(A, B) = map(int, input().split())
(prod, nprod) = sumProd(A, B)
(xor, nxor) = sumXor(A, B)
result = prod * nxor * pow(10, len('%d' % B) + 1) + nprod * xor
print(result)


def gcd(x, y):
	while y != 0:
		(x, y) = (y, x % y)
	return x

def sumProdRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x * y)
	return (sum(all), len(all))

def sumXorRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x ^ y)
	return (sum(all), len(all))

def sumProdOneDivider(divider, limit):
	count = limit // divider
	return (divider * (count + 1) * count // 2, count)

def get(result, x, limit):
	items = result.items()[:]
	if x not in result:
		result[x] = 0
	result[x] += 1
	if result[x] == 0:
		del result[x]
	for (d, v) in items:
		dx = d * x
		if dx > limit:
			continue
		if dx not in result:
			result[dx] = 0
		result[dx] -= v
		if result[dx] == 0:
			del result[dx]
	return result

def getInterval(start, finish, limit):
	result = {}
	for x in range(start, finish):
		items = list(result.items())[:]
		isdiv = False
		for d in range(start, x):
			if x % d == 0:
				isdiv = True
				break
		if isdiv:
			continue
		result[x] = 1
		for (d, v) in items:
			dx = d * x // gcd(d, x)
			if dx > limit:
				continue
			if dx not in result:
				result[dx] = 0
			result[dx] -= v
			if result[dx] == 0:
				del result[dx]
	return result

def sumProd(A, B):
	all = set()
	s = 0
	l = 0
	for x in range(A, 0, -1):
		process = getInterval(x, A + 1, A * B)
		for (d, v) in process.items():
			(sx0, lx0) = sumProdOneDivider(d, B * (x - 1))
			(sx1, lx1) = sumProdOneDivider(d, B * x)
			s += v * (sx1 - sx0)
			l += v * (lx1 - lx0)
	return (s, l)

def sumXor(A, B):
	if B < 100:
		return sumXorRef(A, B)
	b = B - 100
	s = b * (b + 1) // 2
	l = b + 1
	all = set()
	for x in range(1, A + 1):
		for y in range(b + 1, B + 1):
			xy = x ^ y
			if xy <= b:
				continue
			all.add(xy)
	s += sum(all)
	l += len(all)
	return (s, l)
(A, B) = map(int, input().split())
(prod, nprod) = sumProd(A, B)
(xor, nxor) = sumXor(A, B)
result = prod * nxor * pow(10, len('%d' % B) + 1) + nprod * xor
print(result)


def gcd(x, y):
	while y != 0:
		(x, y) = (y, x % y)
	return x

def sumProdRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x * y)
	return (sum(all), len(all))

def sumXorRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x ^ y)
	return (sum(all), len(all))

def sumProdOneDivider(divider, limit):
	count = limit // divider
	return (divider * (count + 1) * count // 2, count)

def get(result, x, limit):
	items = result.items()[:]
	if x not in result:
		result[x] = 0
	result[x] += 1
	if result[x] == 0:
		del result[x]
	for (d, v) in items:
		dx = d * x
		if dx > limit:
			continue
		if dx not in result:
			result[dx] = 0
		result[dx] -= v
		if result[dx] == 0:
			del result[dx]
	return result

def getInterval(start, finish, limit):
	result = {}
	for x in range(start, finish):
		items = list(result.items())[:]
		isdiv = False
		for d in range(start, x):
			if x % d == 0:
				isdiv = True
				break
		if isdiv:
			continue
		result[x] = 1
		for (d, v) in items:
			dx = d * x // gcd(d, x)
			if dx > limit:
				continue
			if dx not in result:
				result[dx] = 0
			result[dx] -= v
			if result[dx] == 0:
				del result[dx]
	return result

def sumProd(A, B):
	all = set()
	s = 0
	l = 0
	for x in range(A, 0, -1):
		process = getInterval(x, A + 1, A * B)
		for (d, v) in process.items():
			(sx0, lx0) = sumProdOneDivider(d, B * (x - 1))
			(sx1, lx1) = sumProdOneDivider(d, B * x)
			s += v * (sx1 - sx0)
			l += v * (lx1 - lx0)
	return (s, l)

def sumXor(A, B):
	if B < 100:
		return sumXorRef(A, B)
	b = B - 100
	s = b * (b + 1) // 2
	l = b + 1
	all = set()
	for x in range(1, A + 1):
		for y in range(b + 1, B + 1):
			xy = x ^ y
			if xy <= b:
				continue
			all.add(xy)
	s += sum(all)
	l += len(all)
	return (s, l)
(A, B) = map(int, input().split())
(prod, nprod) = sumProd(A, B)
(xor, nxor) = sumXor(A, B)
result = prod * nxor * pow(10, len('%d' % B) + 1) + nprod * xor
print(result)


def gcd(x, y):
	while y != 0:
		(x, y) = (y, x % y)
	return x

def sumProdRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x * y)
	return (sum(all), len(all))

def sumXorRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x ^ y)
	return (sum(all), len(all))

def sumProdOneDivider(divider, limit):
	count = limit // divider
	return (divider * (count + 1) * count // 2, count)

def get(result, x, limit):
	items = result.items()[:]
	if x not in result:
		result[x] = 0
	result[x] += 1
	if result[x] == 0:
		del result[x]
	for (d, v) in items:
		dx = d * x
		if dx > limit:
			continue
		if dx not in result:
			result[dx] = 0
		result[dx] -= v
		if result[dx] == 0:
			del result[dx]
	return result

def getInterval(start, finish, limit):
	result = {}
	for x in range(start, finish):
		items = list(result.items())[:]
		isdiv = False
		for d in range(start, x):
			if x % d == 0:
				isdiv = True
				break
		if isdiv:
			continue
		result[x] = 1
		for (d, v) in items:
			dx = d * x // gcd(d, x)
			if dx > limit:
				continue
			if dx not in result:
				result[dx] = 0
			result[dx] -= v
			if result[dx] == 0:
				del result[dx]
	return result

def sumProd(A, B):
	all = set()
	s = 0
	l = 0
	for x in range(A, 0, -1):
		process = getInterval(x, A + 1, A * B)
		for (d, v) in process.items():
			(sx0, lx0) = sumProdOneDivider(d, B * (x - 1))
			(sx1, lx1) = sumProdOneDivider(d, B * x)
			s += v * (sx1 - sx0)
			l += v * (lx1 - lx0)
	return (s, l)

def sumXor(A, B):
	if B < 100:
		return sumXorRef(A, B)
	b = B - 100
	s = b * (b + 1) // 2
	l = b + 1
	all = set()
	for x in range(1, A + 1):
		for y in range(b + 1, B + 1):
			xy = x ^ y
			if xy <= b:
				continue
			all.add(xy)
	s += sum(all)
	l += len(all)
	return (s, l)
(A, B) = map(int, input().split())
(prod, nprod) = sumProd(A, B)
(xor, nxor) = sumXor(A, B)
result = prod * nxor * pow(10, len('%d' % B) + 1) + nprod * xor
print(result)


def gcd(x, y):
	while y != 0:
		(x, y) = (y, x % y)
	return x

def sumProdRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x * y)
	return (sum(all), len(all))

def sumXorRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x ^ y)
	return (sum(all), len(all))

def sumProdOneDivider(divider, limit):
	count = limit // divider
	return (divider * (count + 1) * count // 2, count)

def get(result, x, limit):
	items = result.items()[:]
	if x not in result:
		result[x] = 0
	result[x] += 1
	if result[x] == 0:
		del result[x]
	for (d, v) in items:
		dx = d * x
		if dx > limit:
			continue
		if dx not in result:
			result[dx] = 0
		result[dx] -= v
		if result[dx] == 0:
			del result[dx]
	return result

def getInterval(start, finish, limit):
	result = {}
	for x in range(start, finish):
		items = list(result.items())[:]
		isdiv = False
		for d in range(start, x):
			if x % d == 0:
				isdiv = True
				break
		if isdiv:
			continue
		result[x] = 1
		for (d, v) in items:
			dx = d * x // gcd(d, x)
			if dx > limit:
				continue
			if dx not in result:
				result[dx] = 0
			result[dx] -= v
			if result[dx] == 0:
				del result[dx]
	return result

def sumProd(A, B):
	all = set()
	s = 0
	l = 0
	for x in range(A, 0, -1):
		process = getInterval(x, A + 1, A * B)
		for (d, v) in process.items():
			(sx0, lx0) = sumProdOneDivider(d, B * (x - 1))
			(sx1, lx1) = sumProdOneDivider(d, B * x)
			s += v * (sx1 - sx0)
			l += v * (lx1 - lx0)
	return (s, l)

def sumXor(A, B):
	if B < 100:
		return sumXorRef(A, B)
	b = B - 100
	s = b * (b + 1) // 2
	l = b + 1
	all = set()
	for x in range(1, A + 1):
		for y in range(b + 1, B + 1):
			xy = x ^ y
			if xy <= b:
				continue
			all.add(xy)
	s += sum(all)
	l += len(all)
	return (s, l)
(A, B) = map(int, input().split())
(prod, nprod) = sumProd(A, B)
(xor, nxor) = sumXor(A, B)
result = prod * nxor * pow(10, len('%d' % B) + 1) + nprod * xor
print(result)


def gcd(x, y):
	while y != 0:
		(x, y) = (y, x % y)
	return x

def sumProdRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x * y)
	return (sum(all), len(all))

def sumXorRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x ^ y)
	return (sum(all), len(all))

def sumProdOneDivider(divider, limit):
	count = limit // divider
	return (divider * (count + 1) * count // 2, count)

def get(result, x, limit):
	items = result.items()[:]
	if x not in result:
		result[x] = 0
	result[x] += 1
	if result[x] == 0:
		del result[x]
	for (d, v) in items:
		dx = d * x
		if dx > limit:
			continue
		if dx not in result:
			result[dx] = 0
		result[dx] -= v
		if result[dx] == 0:
			del result[dx]
	return result

def getInterval(start, finish, limit):
	result = {}
	for x in range(start, finish):
		items = list(result.items())[:]
		isdiv = False
		for d in range(start, x):
			if x % d == 0:
				isdiv = True
				break
		if isdiv:
			continue
		result[x] = 1
		for (d, v) in items:
			dx = d * x // gcd(d, x)
			if dx > limit:
				continue
			if dx not in result:
				result[dx] = 0
			result[dx] -= v
			if result[dx] == 0:
				del result[dx]
	return result

def sumProd(A, B):
	all = set()
	s = 0
	l = 0
	for x in range(A, 0, -1):
		process = getInterval(x, A + 1, A * B)
		for (d, v) in process.items():
			(sx0, lx0) = sumProdOneDivider(d, B * (x - 1))
			(sx1, lx1) = sumProdOneDivider(d, B * x)
			s += v * (sx1 - sx0)
			l += v * (lx1 - lx0)
	return (s, l)

def sumXor(A, B):
	if B < 100:
		return sumXorRef(A, B)
	b = B - 100
	s = b * (b + 1) // 2
	l = b + 1
	all = set()
	for x in range(1, A + 1):
		for y in range(b + 1, B + 1):
			xy = x ^ y
			if xy <= b:
				continue
			all.add(xy)
	s += sum(all)
	l += len(all)
	return (s, l)
(A, B) = map(int, input().split())
(prod, nprod) = sumProd(A, B)
(xor, nxor) = sumXor(A, B)
result = prod * nxor * pow(10, len('%d' % B) + 1) + nprod * xor
print(result)


def gcd(x, y):
	while y != 0:
		(x, y) = (y, x % y)
	return x

def sumProdRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x * y)
	return (sum(all), len(all))

def sumXorRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x ^ y)
	return (sum(all), len(all))

def sumProdOneDivider(divider, limit):
	count = limit // divider
	return (divider * (count + 1) * count // 2, count)

def get(result, x, limit):
	items = result.items()[:]
	if x not in result:
		result[x] = 0
	result[x] += 1
	if result[x] == 0:
		del result[x]
	for (d, v) in items:
		dx = d * x
		if dx > limit:
			continue
		if dx not in result:
			result[dx] = 0
		result[dx] -= v
		if result[dx] == 0:
			del result[dx]
	return result

def getInterval(start, finish, limit):
	result = {}
	for x in range(start, finish):
		items = list(result.items())[:]
		isdiv = False
		for d in range(start, x):
			if x % d == 0:
				isdiv = True
				break
		if isdiv:
			continue
		result[x] = 1
		for (d, v) in items:
			dx = d * x // gcd(d, x)
			if dx > limit:
				continue
			if dx not in result:
				result[dx] = 0
			result[dx] -= v
			if result[dx] == 0:
				del result[dx]
	return result

def sumProd(A, B):
	all = set()
	s = 0
	l = 0
	for x in range(A, 0, -1):
		process = getInterval(x, A + 1, A * B)
		for (d, v) in process.items():
			(sx0, lx0) = sumProdOneDivider(d, B * (x - 1))
			(sx1, lx1) = sumProdOneDivider(d, B * x)
			s += v * (sx1 - sx0)
			l += v * (lx1 - lx0)
	return (s, l)

def sumXor(A, B):
	if B < 100:
		return sumXorRef(A, B)
	b = B - 100
	s = b * (b + 1) // 2
	l = b + 1
	all = set()
	for x in range(1, A + 1):
		for y in range(b + 1, B + 1):
			xy = x ^ y
			if xy <= b:
				continue
			all.add(xy)
	s += sum(all)
	l += len(all)
	return (s, l)
(A, B) = map(int, input().split())
(prod, nprod) = sumProd(A, B)
(xor, nxor) = sumXor(A, B)
result = prod * nxor * pow(10, len('%d' % B) + 1) + nprod * xor
print(result)


def gcd(x, y):
	while y != 0:
		(x, y) = (y, x % y)
	return x

def sumProdRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x * y)
	return (sum(all), len(all))

def sumXorRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x ^ y)
	return (sum(all), len(all))

def sumProdOneDivider(divider, limit):
	count = limit // divider
	return (divider * (count + 1) * count // 2, count)

def get(result, x, limit):
	items = result.items()[:]
	if x not in result:
		result[x] = 0
	result[x] += 1
	if result[x] == 0:
		del result[x]
	for (d, v) in items:
		dx = d * x
		if dx > limit:
			continue
		if dx not in result:
			result[dx] = 0
		result[dx] -= v
		if result[dx] == 0:
			del result[dx]
	return result

def getInterval(start, finish, limit):
	result = {}
	for x in range(start, finish):
		items = list(result.items())[:]
		isdiv = False
		for d in range(start, x):
			if x % d == 0:
				isdiv = True
				break
		if isdiv:
			continue
		result[x] = 1
		for (d, v) in items:
			dx = d * x // gcd(d, x)
			if dx > limit:
				continue
			if dx not in result:
				result[dx] = 0
			result[dx] -= v
			if result[dx] == 0:
				del result[dx]
	return result

def sumProd(A, B):
	all = set()
	s = 0
	l = 0
	for x in range(A, 0, -1):
		process = getInterval(x, A + 1, A * B)
		for (d, v) in process.items():
			(sx0, lx0) = sumProdOneDivider(d, B * (x - 1))
			(sx1, lx1) = sumProdOneDivider(d, B * x)
			s += v * (sx1 - sx0)
			l += v * (lx1 - lx0)
	return (s, l)

def sumXor(A, B):
	if B < 100:
		return sumXorRef(A, B)
	b = B - 100
	s = b * (b + 1) // 2
	l = b + 1
	all = set()
	for x in range(1, A + 1):
		for y in range(b + 1, B + 1):
			xy = x ^ y
			if xy <= b:
				continue
			all.add(xy)
	s += sum(all)
	l += len(all)
	return (s, l)
(A, B) = map(int, input().split())
(prod, nprod) = sumProd(A, B)
(xor, nxor) = sumXor(A, B)
result = prod * nxor * pow(10, len('%d' % B) + 1) + nprod * xor
print(result)


def gcd(x, y):
	while y != 0:
		(x, y) = (y, x % y)
	return x

def sumProdRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x * y)
	return (sum(all), len(all))

def sumXorRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x ^ y)
	return (sum(all), len(all))

def sumProdOneDivider(divider, limit):
	count = limit // divider
	return (divider * (count + 1) * count // 2, count)

def get(result, x, limit):
	items = result.items()[:]
	if x not in result:
		result[x] = 0
	result[x] += 1
	if result[x] == 0:
		del result[x]
	for (d, v) in items:
		dx = d * x
		if dx > limit:
			continue
		if dx not in result:
			result[dx] = 0
		result[dx] -= v
		if result[dx] == 0:
			del result[dx]
	return result

def getInterval(start, finish, limit):
	result = {}
	for x in range(start, finish):
		items = list(result.items())[:]
		isdiv = False
		for d in range(start, x):
			if x % d == 0:
				isdiv = True
				break
		if isdiv:
			continue
		result[x] = 1
		for (d, v) in items:
			dx = d * x // gcd(d, x)
			if dx > limit:
				continue
			if dx not in result:
				result[dx] = 0
			result[dx] -= v
			if result[dx] == 0:
				del result[dx]
	return result

def sumProd(A, B):
	all = set()
	s = 0
	l = 0
	for x in range(A, 0, -1):
		process = getInterval(x, A + 1, A * B)
		for (d, v) in process.items():
			(sx0, lx0) = sumProdOneDivider(d, B * (x - 1))
			(sx1, lx1) = sumProdOneDivider(d, B * x)
			s += v * (sx1 - sx0)
			l += v * (lx1 - lx0)
	return (s, l)

def sumXor(A, B):
	if B < 100:
		return sumXorRef(A, B)
	b = B - 100
	s = b * (b + 1) // 2
	l = b + 1
	all = set()
	for x in range(1, A + 1):
		for y in range(b + 1, B + 1):
			xy = x ^ y
			if xy <= b:
				continue
			all.add(xy)
	s += sum(all)
	l += len(all)
	return (s, l)
(A, B) = map(int, input().split())
(prod, nprod) = sumProd(A, B)
(xor, nxor) = sumXor(A, B)
result = prod * nxor * pow(10, len('%d' % B) + 1) + nprod * xor
print(result)


def gcd(x, y):
	while y != 0:
		(x, y) = (y, x % y)
	return x

def sumProdRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x * y)
	return (sum(all), len(all))

def sumXorRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x ^ y)
	return (sum(all), len(all))

def sumProdOneDivider(divider, limit):
	count = limit // divider
	return (divider * (count + 1) * count // 2, count)

def get(result, x, limit):
	items = result.items()[:]
	if x not in result:
		result[x] = 0
	result[x] += 1
	if result[x] == 0:
		del result[x]
	for (d, v) in items:
		dx = d * x
		if dx > limit:
			continue
		if dx not in result:
			result[dx] = 0
		result[dx] -= v
		if result[dx] == 0:
			del result[dx]
	return result

def getInterval(start, finish, limit):
	result = {}
	for x in range(start, finish):
		items = list(result.items())[:]
		isdiv = False
		for d in range(start, x):
			if x % d == 0:
				isdiv = True
				break
		if isdiv:
			continue
		result[x] = 1
		for (d, v) in items:
			dx = d * x // gcd(d, x)
			if dx > limit:
				continue
			if dx not in result:
				result[dx] = 0
			result[dx] -= v
			if result[dx] == 0:
				del result[dx]
	return result

def sumProd(A, B):
	all = set()
	s = 0
	l = 0
	for x in range(A, 0, -1):
		process = getInterval(x, A + 1, A * B)
		for (d, v) in process.items():
			(sx0, lx0) = sumProdOneDivider(d, B * (x - 1))
			(sx1, lx1) = sumProdOneDivider(d, B * x)
			s += v * (sx1 - sx0)
			l += v * (lx1 - lx0)
	return (s, l)

def sumXor(A, B):
	if B < 100:
		return sumXorRef(A, B)
	b = B - 100
	s = b * (b + 1) // 2
	l = b + 1
	all = set()
	for x in range(1, A + 1):
		for y in range(b + 1, B + 1):
			xy = x ^ y
			if xy <= b:
				continue
			all.add(xy)
	s += sum(all)
	l += len(all)
	return (s, l)
(A, B) = map(int, input().split())
(prod, nprod) = sumProd(A, B)
(xor, nxor) = sumXor(A, B)
result = prod * nxor * pow(10, len('%d' % B) + 1) + nprod * xor
print(result)


def gcd(x, y):
	while y != 0:
		(x, y) = (y, x % y)
	return x

def sumProdRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x * y)
	return (sum(all), len(all))

def sumXorRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x ^ y)
	return (sum(all), len(all))

def sumProdOneDivider(divider, limit):
	count = limit // divider
	return (divider * (count + 1) * count // 2, count)

def get(result, x, limit):
	items = result.items()[:]
	if x not in result:
		result[x] = 0
	result[x] += 1
	if result[x] == 0:
		del result[x]
	for (d, v) in items:
		dx = d * x
		if dx > limit:
			continue
		if dx not in result:
			result[dx] = 0
		result[dx] -= v
		if result[dx] == 0:
			del result[dx]
	return result

def getInterval(start, finish, limit):
	result = {}
	for x in range(start, finish):
		items = list(result.items())[:]
		isdiv = False
		for d in range(start, x):
			if x % d == 0:
				isdiv = True
				break
		if isdiv:
			continue
		result[x] = 1
		for (d, v) in items:
			dx = d * x // gcd(d, x)
			if dx > limit:
				continue
			if dx not in result:
				result[dx] = 0
			result[dx] -= v
			if result[dx] == 0:
				del result[dx]
	return result

def sumProd(A, B):
	all = set()
	s = 0
	l = 0
	for x in range(A, 0, -1):
		process = getInterval(x, A + 1, A * B)
		for (d, v) in process.items():
			(sx0, lx0) = sumProdOneDivider(d, B * (x - 1))
			(sx1, lx1) = sumProdOneDivider(d, B * x)
			s += v * (sx1 - sx0)
			l += v * (lx1 - lx0)
	return (s, l)

def sumXor(A, B):
	if B < 100:
		return sumXorRef(A, B)
	b = B - 100
	s = b * (b + 1) // 2
	l = b + 1
	all = set()
	for x in range(1, A + 1):
		for y in range(b + 1, B + 1):
			xy = x ^ y
			if xy <= b:
				continue
			all.add(xy)
	s += sum(all)
	l += len(all)
	return (s, l)
(A, B) = map(int, input().split())
(prod, nprod) = sumProd(A, B)
(xor, nxor) = sumXor(A, B)
result = prod * nxor * pow(10, len('%d' % B) + 1) + nprod * xor
print(result)


def gcd(x, y):
	while y != 0:
		(x, y) = (y, x % y)
	return x

def sumProdRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x * y)
	return (sum(all), len(all))

def sumXorRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x ^ y)
	return (sum(all), len(all))

def sumProdOneDivider(divider, limit):
	count = limit // divider
	return (divider * (count + 1) * count // 2, count)

def get(result, x, limit):
	items = result.items()[:]
	if x not in result:
		result[x] = 0
	result[x] += 1
	if result[x] == 0:
		del result[x]
	for (d, v) in items:
		dx = d * x
		if dx > limit:
			continue
		if dx not in result:
			result[dx] = 0
		result[dx] -= v
		if result[dx] == 0:
			del result[dx]
	return result

def getInterval(start, finish, limit):
	result = {}
	for x in range(start, finish):
		items = list(result.items())[:]
		isdiv = False
		for d in range(start, x):
			if x % d == 0:
				isdiv = True
				break
		if isdiv:
			continue
		result[x] = 1
		for (d, v) in items:
			dx = d * x // gcd(d, x)
			if dx > limit:
				continue
			if dx not in result:
				result[dx] = 0
			result[dx] -= v
			if result[dx] == 0:
				del result[dx]
	return result

def sumProd(A, B):
	all = set()
	s = 0
	l = 0
	for x in range(A, 0, -1):
		process = getInterval(x, A + 1, A * B)
		for (d, v) in process.items():
			(sx0, lx0) = sumProdOneDivider(d, B * (x - 1))
			(sx1, lx1) = sumProdOneDivider(d, B * x)
			s += v * (sx1 - sx0)
			l += v * (lx1 - lx0)
	return (s, l)

def sumXor(A, B):
	if B < 100:
		return sumXorRef(A, B)
	b = B - 100
	s = b * (b + 1) // 2
	l = b + 1
	all = set()
	for x in range(1, A + 1):
		for y in range(b + 1, B + 1):
			xy = x ^ y
			if xy <= b:
				continue
			all.add(xy)
	s += sum(all)
	l += len(all)
	return (s, l)
(A, B) = map(int, input().split())
(prod, nprod) = sumProd(A, B)
(xor, nxor) = sumXor(A, B)
result = prod * nxor * pow(10, len('%d' % B) + 1) + nprod * xor
print(result)


def gcd(x, y):
	while y != 0:
		(x, y) = (y, x % y)
	return x

def sumProdRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x * y)
	return (sum(all), len(all))

def sumXorRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x ^ y)
	return (sum(all), len(all))

def sumProdOneDivider(divider, limit):
	count = limit // divider
	return (divider * (count + 1) * count // 2, count)

def get(result, x, limit):
	items = result.items()[:]
	if x not in result:
		result[x] = 0
	result[x] += 1
	if result[x] == 0:
		del result[x]
	for (d, v) in items:
		dx = d * x
		if dx > limit:
			continue
		if dx not in result:
			result[dx] = 0
		result[dx] -= v
		if result[dx] == 0:
			del result[dx]
	return result

def getInterval(start, finish, limit):
	result = {}
	for x in range(start, finish):
		items = list(result.items())[:]
		isdiv = False
		for d in range(start, x):
			if x % d == 0:
				isdiv = True
				break
		if isdiv:
			continue
		result[x] = 1
		for (d, v) in items:
			dx = d * x // gcd(d, x)
			if dx > limit:
				continue
			if dx not in result:
				result[dx] = 0
			result[dx] -= v
			if result[dx] == 0:
				del result[dx]
	return result

def sumProd(A, B):
	all = set()
	s = 0
	l = 0
	for x in range(A, 0, -1):
		process = getInterval(x, A + 1, A * B)
		for (d, v) in process.items():
			(sx0, lx0) = sumProdOneDivider(d, B * (x - 1))
			(sx1, lx1) = sumProdOneDivider(d, B * x)
			s += v * (sx1 - sx0)
			l += v * (lx1 - lx0)
	return (s, l)

def sumXor(A, B):
	if B < 100:
		return sumXorRef(A, B)
	b = B - 100
	s = b * (b + 1) // 2
	l = b + 1
	all = set()
	for x in range(1, A + 1):
		for y in range(b + 1, B + 1):
			xy = x ^ y
			if xy <= b:
				continue
			all.add(xy)
	s += sum(all)
	l += len(all)
	return (s, l)
(A, B) = map(int, input().split())
(prod, nprod) = sumProd(A, B)
(xor, nxor) = sumXor(A, B)
result = prod * nxor * pow(10, len('%d' % B) + 1) + nprod * xor
print(result)


def gcd(x, y):
	while y != 0:
		(x, y) = (y, x % y)
	return x

def sumProdRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x * y)
	return (sum(all), len(all))

def sumXorRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x ^ y)
	return (sum(all), len(all))

def sumProdOneDivider(divider, limit):
	count = limit // divider
	return (divider * (count + 1) * count // 2, count)

def get(result, x, limit):
	items = result.items()[:]
	if x not in result:
		result[x] = 0
	result[x] += 1
	if result[x] == 0:
		del result[x]
	for (d, v) in items:
		dx = d * x
		if dx > limit:
			continue
		if dx not in result:
			result[dx] = 0
		result[dx] -= v
		if result[dx] == 0:
			del result[dx]
	return result

def getInterval(start, finish, limit):
	result = {}
	for x in range(start, finish):
		items = list(result.items())[:]
		isdiv = False
		for d in range(start, x):
			if x % d == 0:
				isdiv = True
				break
		if isdiv:
			continue
		result[x] = 1
		for (d, v) in items:
			dx = d * x // gcd(d, x)
			if dx > limit:
				continue
			if dx not in result:
				result[dx] = 0
			result[dx] -= v
			if result[dx] == 0:
				del result[dx]
	return result

def sumProd(A, B):
	all = set()
	s = 0
	l = 0
	for x in range(A, 0, -1):
		process = getInterval(x, A + 1, A * B)
		for (d, v) in process.items():
			(sx0, lx0) = sumProdOneDivider(d, B * (x - 1))
			(sx1, lx1) = sumProdOneDivider(d, B * x)
			s += v * (sx1 - sx0)
			l += v * (lx1 - lx0)
	return (s, l)

def sumXor(A, B):
	if B < 100:
		return sumXorRef(A, B)
	b = B - 100
	s = b * (b + 1) // 2
	l = b + 1
	all = set()
	for x in range(1, A + 1):
		for y in range(b + 1, B + 1):
			xy = x ^ y
			if xy <= b:
				continue
			all.add(xy)
	s += sum(all)
	l += len(all)
	return (s, l)
(A, B) = map(int, input().split())
(prod, nprod) = sumProd(A, B)
(xor, nxor) = sumXor(A, B)
result = prod * nxor * pow(10, len('%d' % B) + 1) + nprod * xor
print(result)


def gcd(x, y):
	while y != 0:
		(x, y) = (y, x % y)
	return x

def sumProdRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x * y)
	return (sum(all), len(all))

def sumXorRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x ^ y)
	return (sum(all), len(all))

def sumProdOneDivider(divider, limit):
	count = limit // divider
	return (divider * (count + 1) * count // 2, count)

def get(result, x, limit):
	items = result.items()[:]
	if x not in result:
		result[x] = 0
	result[x] += 1
	if result[x] == 0:
		del result[x]
	for (d, v) in items:
		dx = d * x
		if dx > limit:
			continue
		if dx not in result:
			result[dx] = 0
		result[dx] -= v
		if result[dx] == 0:
			del result[dx]
	return result

def getInterval(start, finish, limit):
	result = {}
	for x in range(start, finish):
		items = list(result.items())[:]
		isdiv = False
		for d in range(start, x):
			if x % d == 0:
				isdiv = True
				break
		if isdiv:
			continue
		result[x] = 1
		for (d, v) in items:
			dx = d * x // gcd(d, x)
			if dx > limit:
				continue
			if dx not in result:
				result[dx] = 0
			result[dx] -= v
			if result[dx] == 0:
				del result[dx]
	return result

def sumProd(A, B):
	all = set()
	s = 0
	l = 0
	for x in range(A, 0, -1):
		process = getInterval(x, A + 1, A * B)
		for (d, v) in process.items():
			(sx0, lx0) = sumProdOneDivider(d, B * (x - 1))
			(sx1, lx1) = sumProdOneDivider(d, B * x)
			s += v * (sx1 - sx0)
			l += v * (lx1 - lx0)
	return (s, l)

def sumXor(A, B):
	if B < 100:
		return sumXorRef(A, B)
	b = B - 100
	s = b * (b + 1) // 2
	l = b + 1
	all = set()
	for x in range(1, A + 1):
		for y in range(b + 1, B + 1):
			xy = x ^ y
			if xy <= b:
				continue
			all.add(xy)
	s += sum(all)
	l += len(all)
	return (s, l)
(A, B) = map(int, input().split())
(prod, nprod) = sumProd(A, B)
(xor, nxor) = sumXor(A, B)
result = prod * nxor * pow(10, len('%d' % B) + 1) + nprod * xor
print(result)


def gcd(x, y):
	while y != 0:
		(x, y) = (y, x % y)
	return x

def sumProdRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x * y)
	return (sum(all), len(all))

def sumXorRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x ^ y)
	return (sum(all), len(all))

def sumProdOneDivider(divider, limit):
	count = limit // divider
	return (divider * (count + 1) * count // 2, count)

def get(result, x, limit):
	items = result.items()[:]
	if x not in result:
		result[x] = 0
	result[x] += 1
	if result[x] == 0:
		del result[x]
	for (d, v) in items:
		dx = d * x
		if dx > limit:
			continue
		if dx not in result:
			result[dx] = 0
		result[dx] -= v
		if result[dx] == 0:
			del result[dx]
	return result

def getInterval(start, finish, limit):
	result = {}
	for x in range(start, finish):
		items = list(result.items())[:]
		isdiv = False
		for d in range(start, x):
			if x % d == 0:
				isdiv = True
				break
		if isdiv:
			continue
		result[x] = 1
		for (d, v) in items:
			dx = d * x // gcd(d, x)
			if dx > limit:
				continue
			if dx not in result:
				result[dx] = 0
			result[dx] -= v
			if result[dx] == 0:
				del result[dx]
	return result

def sumProd(A, B):
	all = set()
	s = 0
	l = 0
	for x in range(A, 0, -1):
		process = getInterval(x, A + 1, A * B)
		for (d, v) in process.items():
			(sx0, lx0) = sumProdOneDivider(d, B * (x - 1))
			(sx1, lx1) = sumProdOneDivider(d, B * x)
			s += v * (sx1 - sx0)
			l += v * (lx1 - lx0)
	return (s, l)

def sumXor(A, B):
	if B < 100:
		return sumXorRef(A, B)
	b = B - 100
	s = b * (b + 1) // 2
	l = b + 1
	all = set()
	for x in range(1, A + 1):
		for y in range(b + 1, B + 1):
			xy = x ^ y
			if xy <= b:
				continue
			all.add(xy)
	s += sum(all)
	l += len(all)
	return (s, l)
(A, B) = map(int, input().split())
(prod, nprod) = sumProd(A, B)
(xor, nxor) = sumXor(A, B)
result = prod * nxor * pow(10, len('%d' % B) + 1) + nprod * xor
print(result)


def gcd(x, y):
	while y != 0:
		(x, y) = (y, x % y)
	return x

def sumProdRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x * y)
	return (sum(all), len(all))

def sumXorRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x ^ y)
	return (sum(all), len(all))

def sumProdOneDivider(divider, limit):
	count = limit // divider
	return (divider * (count + 1) * count // 2, count)

def get(result, x, limit):
	items = result.items()[:]
	if x not in result:
		result[x] = 0
	result[x] += 1
	if result[x] == 0:
		del result[x]
	for (d, v) in items:
		dx = d * x
		if dx > limit:
			continue
		if dx not in result:
			result[dx] = 0
		result[dx] -= v
		if result[dx] == 0:
			del result[dx]
	return result

def getInterval(start, finish, limit):
	result = {}
	for x in range(start, finish):
		items = list(result.items())[:]
		isdiv = False
		for d in range(start, x):
			if x % d == 0:
				isdiv = True
				break
		if isdiv:
			continue
		result[x] = 1
		for (d, v) in items:
			dx = d * x // gcd(d, x)
			if dx > limit:
				continue
			if dx not in result:
				result[dx] = 0
			result[dx] -= v
			if result[dx] == 0:
				del result[dx]
	return result

def sumProd(A, B):
	all = set()
	s = 0
	l = 0
	for x in range(A, 0, -1):
		process = getInterval(x, A + 1, A * B)
		for (d, v) in process.items():
			(sx0, lx0) = sumProdOneDivider(d, B * (x - 1))
			(sx1, lx1) = sumProdOneDivider(d, B * x)
			s += v * (sx1 - sx0)
			l += v * (lx1 - lx0)
	return (s, l)

def sumXor(A, B):
	if B < 100:
		return sumXorRef(A, B)
	b = B - 100
	s = b * (b + 1) // 2
	l = b + 1
	all = set()
	for x in range(1, A + 1):
		for y in range(b + 1, B + 1):
			xy = x ^ y
			if xy <= b:
				continue
			all.add(xy)
	s += sum(all)
	l += len(all)
	return (s, l)
(A, B) = map(int, input().split())
(prod, nprod) = sumProd(A, B)
(xor, nxor) = sumXor(A, B)
result = prod * nxor * pow(10, len('%d' % B) + 1) + nprod * xor
print(result)


def gcd(x, y):
	while y != 0:
		(x, y) = (y, x % y)
	return x

def sumProdRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x * y)
	return (sum(all), len(all))

def sumXorRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x ^ y)
	return (sum(all), len(all))

def sumProdOneDivider(divider, limit):
	count = limit // divider
	return (divider * (count + 1) * count // 2, count)

def get(result, x, limit):
	items = result.items()[:]
	if x not in result:
		result[x] = 0
	result[x] += 1
	if result[x] == 0:
		del result[x]
	for (d, v) in items:
		dx = d * x
		if dx > limit:
			continue
		if dx not in result:
			result[dx] = 0
		result[dx] -= v
		if result[dx] == 0:
			del result[dx]
	return result

def getInterval(start, finish, limit):
	result = {}
	for x in range(start, finish):
		items = list(result.items())[:]
		isdiv = False
		for d in range(start, x):
			if x % d == 0:
				isdiv = True
				break
		if isdiv:
			continue
		result[x] = 1
		for (d, v) in items:
			dx = d * x // gcd(d, x)
			if dx > limit:
				continue
			if dx not in result:
				result[dx] = 0
			result[dx] -= v
			if result[dx] == 0:
				del result[dx]
	return result

def sumProd(A, B):
	all = set()
	s = 0
	l = 0
	for x in range(A, 0, -1):
		process = getInterval(x, A + 1, A * B)
		for (d, v) in process.items():
			(sx0, lx0) = sumProdOneDivider(d, B * (x - 1))
			(sx1, lx1) = sumProdOneDivider(d, B * x)
			s += v * (sx1 - sx0)
			l += v * (lx1 - lx0)
	return (s, l)

def sumXor(A, B):
	if B < 100:
		return sumXorRef(A, B)
	b = B - 100
	s = b * (b + 1) // 2
	l = b + 1
	all = set()
	for x in range(1, A + 1):
		for y in range(b + 1, B + 1):
			xy = x ^ y
			if xy <= b:
				continue
			all.add(xy)
	s += sum(all)
	l += len(all)
	return (s, l)
(A, B) = map(int, input().split())
(prod, nprod) = sumProd(A, B)
(xor, nxor) = sumXor(A, B)
result = prod * nxor * pow(10, len('%d' % B) + 1) + nprod * xor
print(result)


def gcd(x, y):
	while y != 0:
		(x, y) = (y, x % y)
	return x

def sumProdRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x * y)
	return (sum(all), len(all))

def sumXorRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x ^ y)
	return (sum(all), len(all))

def sumProdOneDivider(divider, limit):
	count = limit // divider
	return (divider * (count + 1) * count // 2, count)

def get(result, x, limit):
	items = result.items()[:]
	if x not in result:
		result[x] = 0
	result[x] += 1
	if result[x] == 0:
		del result[x]
	for (d, v) in items:
		dx = d * x
		if dx > limit:
			continue
		if dx not in result:
			result[dx] = 0
		result[dx] -= v
		if result[dx] == 0:
			del result[dx]
	return result

def getInterval(start, finish, limit):
	result = {}
	for x in range(start, finish):
		items = list(result.items())[:]
		isdiv = False
		for d in range(start, x):
			if x % d == 0:
				isdiv = True
				break
		if isdiv:
			continue
		result[x] = 1
		for (d, v) in items:
			dx = d * x // gcd(d, x)
			if dx > limit:
				continue
			if dx not in result:
				result[dx] = 0
			result[dx] -= v
			if result[dx] == 0:
				del result[dx]
	return result

def sumProd(A, B):
	all = set()
	s = 0
	l = 0
	for x in range(A, 0, -1):
		process = getInterval(x, A + 1, A * B)
		for (d, v) in process.items():
			(sx0, lx0) = sumProdOneDivider(d, B * (x - 1))
			(sx1, lx1) = sumProdOneDivider(d, B * x)
			s += v * (sx1 - sx0)
			l += v * (lx1 - lx0)
	return (s, l)

def sumXor(A, B):
	if B < 100:
		return sumXorRef(A, B)
	b = B - 100
	s = b * (b + 1) // 2
	l = b + 1
	all = set()
	for x in range(1, A + 1):
		for y in range(b + 1, B + 1):
			xy = x ^ y
			if xy <= b:
				continue
			all.add(xy)
	s += sum(all)
	l += len(all)
	return (s, l)
(A, B) = map(int, input().split())
(prod, nprod) = sumProd(A, B)
(xor, nxor) = sumXor(A, B)
result = prod * nxor * pow(10, len('%d' % B) + 1) + nprod * xor
print(result)


def gcd(x, y):
	while y != 0:
		(x, y) = (y, x % y)
	return x

def sumProdRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x * y)
	return (sum(all), len(all))

def sumXorRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x ^ y)
	return (sum(all), len(all))

def sumProdOneDivider(divider, limit):
	count = limit // divider
	return (divider * (count + 1) * count // 2, count)

def get(result, x, limit):
	items = result.items()[:]
	if x not in result:
		result[x] = 0
	result[x] += 1
	if result[x] == 0:
		del result[x]
	for (d, v) in items:
		dx = d * x
		if dx > limit:
			continue
		if dx not in result:
			result[dx] = 0
		result[dx] -= v
		if result[dx] == 0:
			del result[dx]
	return result

def getInterval(start, finish, limit):
	result = {}
	for x in range(start, finish):
		items = list(result.items())[:]
		isdiv = False
		for d in range(start, x):
			if x % d == 0:
				isdiv = True
				break
		if isdiv:
			continue
		result[x] = 1
		for (d, v) in items:
			dx = d * x // gcd(d, x)
			if dx > limit:
				continue
			if dx not in result:
				result[dx] = 0
			result[dx] -= v
			if result[dx] == 0:
				del result[dx]
	return result

def sumProd(A, B):
	all = set()
	s = 0
	l = 0
	for x in range(A, 0, -1):
		process = getInterval(x, A + 1, A * B)
		for (d, v) in process.items():
			(sx0, lx0) = sumProdOneDivider(d, B * (x - 1))
			(sx1, lx1) = sumProdOneDivider(d, B * x)
			s += v * (sx1 - sx0)
			l += v * (lx1 - lx0)
	return (s, l)

def sumXor(A, B):
	if B < 100:
		return sumXorRef(A, B)
	b = B - 100
	s = b * (b + 1) // 2
	l = b + 1
	all = set()
	for x in range(1, A + 1):
		for y in range(b + 1, B + 1):
			xy = x ^ y
			if xy <= b:
				continue
			all.add(xy)
	s += sum(all)
	l += len(all)
	return (s, l)
(A, B) = map(int, input().split())
(prod, nprod) = sumProd(A, B)
(xor, nxor) = sumXor(A, B)
result = prod * nxor * pow(10, len('%d' % B) + 1) + nprod * xor
print(result)


def gcd(x, y):
	while y != 0:
		(x, y) = (y, x % y)
	return x

def sumProdRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x * y)
	return (sum(all), len(all))

def sumXorRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x ^ y)
	return (sum(all), len(all))

def sumProdOneDivider(divider, limit):
	count = limit // divider
	return (divider * (count + 1) * count // 2, count)

def get(result, x, limit):
	items = result.items()[:]
	if x not in result:
		result[x] = 0
	result[x] += 1
	if result[x] == 0:
		del result[x]
	for (d, v) in items:
		dx = d * x
		if dx > limit:
			continue
		if dx not in result:
			result[dx] = 0
		result[dx] -= v
		if result[dx] == 0:
			del result[dx]
	return result

def getInterval(start, finish, limit):
	result = {}
	for x in range(start, finish):
		items = list(result.items())[:]
		isdiv = False
		for d in range(start, x):
			if x % d == 0:
				isdiv = True
				break
		if isdiv:
			continue
		result[x] = 1
		for (d, v) in items:
			dx = d * x // gcd(d, x)
			if dx > limit:
				continue
			if dx not in result:
				result[dx] = 0
			result[dx] -= v
			if result[dx] == 0:
				del result[dx]
	return result

def sumProd(A, B):
	all = set()
	s = 0
	l = 0
	for x in range(A, 0, -1):
		process = getInterval(x, A + 1, A * B)
		for (d, v) in process.items():
			(sx0, lx0) = sumProdOneDivider(d, B * (x - 1))
			(sx1, lx1) = sumProdOneDivider(d, B * x)
			s += v * (sx1 - sx0)
			l += v * (lx1 - lx0)
	return (s, l)

def sumXor(A, B):
	if B < 100:
		return sumXorRef(A, B)
	b = B - 100
	s = b * (b + 1) // 2
	l = b + 1
	all = set()
	for x in range(1, A + 1):
		for y in range(b + 1, B + 1):
			xy = x ^ y
			if xy <= b:
				continue
			all.add(xy)
	s += sum(all)
	l += len(all)
	return (s, l)
(A, B) = map(int, input().split())
(prod, nprod) = sumProd(A, B)
(xor, nxor) = sumXor(A, B)
result = prod * nxor * pow(10, len('%d' % B) + 1) + nprod * xor
print(result)


def gcd(x, y):
	while y != 0:
		(x, y) = (y, x % y)
	return x

def sumProdRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x * y)
	return (sum(all), len(all))

def sumXorRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x ^ y)
	return (sum(all), len(all))

def sumProdOneDivider(divider, limit):
	count = limit // divider
	return (divider * (count + 1) * count // 2, count)

def get(result, x, limit):
	items = result.items()[:]
	if x not in result:
		result[x] = 0
	result[x] += 1
	if result[x] == 0:
		del result[x]
	for (d, v) in items:
		dx = d * x
		if dx > limit:
			continue
		if dx not in result:
			result[dx] = 0
		result[dx] -= v
		if result[dx] == 0:
			del result[dx]
	return result

def getInterval(start, finish, limit):
	result = {}
	for x in range(start, finish):
		items = list(result.items())[:]
		isdiv = False
		for d in range(start, x):
			if x % d == 0:
				isdiv = True
				break
		if isdiv:
			continue
		result[x] = 1
		for (d, v) in items:
			dx = d * x // gcd(d, x)
			if dx > limit:
				continue
			if dx not in result:
				result[dx] = 0
			result[dx] -= v
			if result[dx] == 0:
				del result[dx]
	return result

def sumProd(A, B):
	all = set()
	s = 0
	l = 0
	for x in range(A, 0, -1):
		process = getInterval(x, A + 1, A * B)
		for (d, v) in process.items():
			(sx0, lx0) = sumProdOneDivider(d, B * (x - 1))
			(sx1, lx1) = sumProdOneDivider(d, B * x)
			s += v * (sx1 - sx0)
			l += v * (lx1 - lx0)
	return (s, l)

def sumXor(A, B):
	if B < 100:
		return sumXorRef(A, B)
	b = B - 100
	s = b * (b + 1) // 2
	l = b + 1
	all = set()
	for x in range(1, A + 1):
		for y in range(b + 1, B + 1):
			xy = x ^ y
			if xy <= b:
				continue
			all.add(xy)
	s += sum(all)
	l += len(all)
	return (s, l)
(A, B) = map(int, input().split())
(prod, nprod) = sumProd(A, B)
(xor, nxor) = sumXor(A, B)
result = prod * nxor * pow(10, len('%d' % B) + 1) + nprod * xor
print(result)


def gcd(x, y):
	while y != 0:
		(x, y) = (y, x % y)
	return x

def sumProdRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x * y)
	return (sum(all), len(all))

def sumXorRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x ^ y)
	return (sum(all), len(all))

def sumProdOneDivider(divider, limit):
	count = limit // divider
	return (divider * (count + 1) * count // 2, count)

def get(result, x, limit):
	items = result.items()[:]
	if x not in result:
		result[x] = 0
	result[x] += 1
	if result[x] == 0:
		del result[x]
	for (d, v) in items:
		dx = d * x
		if dx > limit:
			continue
		if dx not in result:
			result[dx] = 0
		result[dx] -= v
		if result[dx] == 0:
			del result[dx]
	return result

def getInterval(start, finish, limit):
	result = {}
	for x in range(start, finish):
		items = list(result.items())[:]
		isdiv = False
		for d in range(start, x):
			if x % d == 0:
				isdiv = True
				break
		if isdiv:
			continue
		result[x] = 1
		for (d, v) in items:
			dx = d * x // gcd(d, x)
			if dx > limit:
				continue
			if dx not in result:
				result[dx] = 0
			result[dx] -= v
			if result[dx] == 0:
				del result[dx]
	return result

def sumProd(A, B):
	all = set()
	s = 0
	l = 0
	for x in range(A, 0, -1):
		process = getInterval(x, A + 1, A * B)
		for (d, v) in process.items():
			(sx0, lx0) = sumProdOneDivider(d, B * (x - 1))
			(sx1, lx1) = sumProdOneDivider(d, B * x)
			s += v * (sx1 - sx0)
			l += v * (lx1 - lx0)
	return (s, l)

def sumXor(A, B):
	if B < 100:
		return sumXorRef(A, B)
	b = B - 100
	s = b * (b + 1) // 2
	l = b + 1
	all = set()
	for x in range(1, A + 1):
		for y in range(b + 1, B + 1):
			xy = x ^ y
			if xy <= b:
				continue
			all.add(xy)
	s += sum(all)
	l += len(all)
	return (s, l)
(A, B) = map(int, input().split())
(prod, nprod) = sumProd(A, B)
(xor, nxor) = sumXor(A, B)
result = prod * nxor * pow(10, len('%d' % B) + 1) + nprod * xor
print(result)


def gcd(x, y):
	while y != 0:
		(x, y) = (y, x % y)
	return x

def sumProdRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x * y)
	return (sum(all), len(all))

def sumXorRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x ^ y)
	return (sum(all), len(all))

def sumProdOneDivider(divider, limit):
	count = limit // divider
	return (divider * (count + 1) * count // 2, count)

def get(result, x, limit):
	items = result.items()[:]
	if x not in result:
		result[x] = 0
	result[x] += 1
	if result[x] == 0:
		del result[x]
	for (d, v) in items:
		dx = d * x
		if dx > limit:
			continue
		if dx not in result:
			result[dx] = 0
		result[dx] -= v
		if result[dx] == 0:
			del result[dx]
	return result

def getInterval(start, finish, limit):
	result = {}
	for x in range(start, finish):
		items = list(result.items())[:]
		isdiv = False
		for d in range(start, x):
			if x % d == 0:
				isdiv = True
				break
		if isdiv:
			continue
		result[x] = 1
		for (d, v) in items:
			dx = d * x // gcd(d, x)
			if dx > limit:
				continue
			if dx not in result:
				result[dx] = 0
			result[dx] -= v
			if result[dx] == 0:
				del result[dx]
	return result

def sumProd(A, B):
	all = set()
	s = 0
	l = 0
	for x in range(A, 0, -1):
		process = getInterval(x, A + 1, A * B)
		for (d, v) in process.items():
			(sx0, lx0) = sumProdOneDivider(d, B * (x - 1))
			(sx1, lx1) = sumProdOneDivider(d, B * x)
			s += v * (sx1 - sx0)
			l += v * (lx1 - lx0)
	return (s, l)

def sumXor(A, B):
	if B < 100:
		return sumXorRef(A, B)
	b = B - 100
	s = b * (b + 1) // 2
	l = b + 1
	all = set()
	for x in range(1, A + 1):
		for y in range(b + 1, B + 1):
			xy = x ^ y
			if xy <= b:
				continue
			all.add(xy)
	s += sum(all)
	l += len(all)
	return (s, l)
(A, B) = map(int, input().split())
(prod, nprod) = sumProd(A, B)
(xor, nxor) = sumXor(A, B)
result = prod * nxor * pow(10, len('%d' % B) + 1) + nprod * xor
print(result)


def gcd(x, y):
	while y != 0:
		(x, y) = (y, x % y)
	return x

def sumProdRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x * y)
	return (sum(all), len(all))

def sumXorRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x ^ y)
	return (sum(all), len(all))

def sumProdOneDivider(divider, limit):
	count = limit // divider
	return (divider * (count + 1) * count // 2, count)

def get(result, x, limit):
	items = result.items()[:]
	if x not in result:
		result[x] = 0
	result[x] += 1
	if result[x] == 0:
		del result[x]
	for (d, v) in items:
		dx = d * x
		if dx > limit:
			continue
		if dx not in result:
			result[dx] = 0
		result[dx] -= v
		if result[dx] == 0:
			del result[dx]
	return result

def getInterval(start, finish, limit):
	result = {}
	for x in range(start, finish):
		items = list(result.items())[:]
		isdiv = False
		for d in range(start, x):
			if x % d == 0:
				isdiv = True
				break
		if isdiv:
			continue
		result[x] = 1
		for (d, v) in items:
			dx = d * x // gcd(d, x)
			if dx > limit:
				continue
			if dx not in result:
				result[dx] = 0
			result[dx] -= v
			if result[dx] == 0:
				del result[dx]
	return result

def sumProd(A, B):
	all = set()
	s = 0
	l = 0
	for x in range(A, 0, -1):
		process = getInterval(x, A + 1, A * B)
		for (d, v) in process.items():
			(sx0, lx0) = sumProdOneDivider(d, B * (x - 1))
			(sx1, lx1) = sumProdOneDivider(d, B * x)
			s += v * (sx1 - sx0)
			l += v * (lx1 - lx0)
	return (s, l)

def sumXor(A, B):
	if B < 100:
		return sumXorRef(A, B)
	b = B - 100
	s = b * (b + 1) // 2
	l = b + 1
	all = set()
	for x in range(1, A + 1):
		for y in range(b + 1, B + 1):
			xy = x ^ y
			if xy <= b:
				continue
			all.add(xy)
	s += sum(all)
	l += len(all)
	return (s, l)
(A, B) = map(int, input().split())
(prod, nprod) = sumProd(A, B)
(xor, nxor) = sumXor(A, B)
result = prod * nxor * pow(10, len('%d' % B) + 1) + nprod * xor
print(result)


def gcd(x, y):
	while y != 0:
		(x, y) = (y, x % y)
	return x

def sumProdRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x * y)
	return (sum(all), len(all))

def sumXorRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x ^ y)
	return (sum(all), len(all))

def sumProdOneDivider(divider, limit):
	count = limit // divider
	return (divider * (count + 1) * count // 2, count)

def get(result, x, limit):
	items = result.items()[:]
	if x not in result:
		result[x] = 0
	result[x] += 1
	if result[x] == 0:
		del result[x]
	for (d, v) in items:
		dx = d * x
		if dx > limit:
			continue
		if dx not in result:
			result[dx] = 0
		result[dx] -= v
		if result[dx] == 0:
			del result[dx]
	return result

def getInterval(start, finish, limit):
	result = {}
	for x in range(start, finish):
		items = list(result.items())[:]
		isdiv = False
		for d in range(start, x):
			if x % d == 0:
				isdiv = True
				break
		if isdiv:
			continue
		result[x] = 1
		for (d, v) in items:
			dx = d * x // gcd(d, x)
			if dx > limit:
				continue
			if dx not in result:
				result[dx] = 0
			result[dx] -= v
			if result[dx] == 0:
				del result[dx]
	return result

def sumProd(A, B):
	all = set()
	s = 0
	l = 0
	for x in range(A, 0, -1):
		process = getInterval(x, A + 1, A * B)
		for (d, v) in process.items():
			(sx0, lx0) = sumProdOneDivider(d, B * (x - 1))
			(sx1, lx1) = sumProdOneDivider(d, B * x)
			s += v * (sx1 - sx0)
			l += v * (lx1 - lx0)
	return (s, l)

def sumXor(A, B):
	if B < 100:
		return sumXorRef(A, B)
	b = B - 100
	s = b * (b + 1) // 2
	l = b + 1
	all = set()
	for x in range(1, A + 1):
		for y in range(b + 1, B + 1):
			xy = x ^ y
			if xy <= b:
				continue
			all.add(xy)
	s += sum(all)
	l += len(all)
	return (s, l)
(A, B) = map(int, input().split())
(prod, nprod) = sumProd(A, B)
(xor, nxor) = sumXor(A, B)
result = prod * nxor * pow(10, len('%d' % B) + 1) + nprod * xor
print(result)


def gcd(x, y):
	while y != 0:
		(x, y) = (y, x % y)
	return x

def sumProdRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x * y)
	return (sum(all), len(all))

def sumXorRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x ^ y)
	return (sum(all), len(all))

def sumProdOneDivider(divider, limit):
	count = limit // divider
	return (divider * (count + 1) * count // 2, count)

def get(result, x, limit):
	items = result.items()[:]
	if x not in result:
		result[x] = 0
	result[x] += 1
	if result[x] == 0:
		del result[x]
	for (d, v) in items:
		dx = d * x
		if dx > limit:
			continue
		if dx not in result:
			result[dx] = 0
		result[dx] -= v
		if result[dx] == 0:
			del result[dx]
	return result

def getInterval(start, finish, limit):
	result = {}
	for x in range(start, finish):
		items = list(result.items())[:]
		isdiv = False
		for d in range(start, x):
			if x % d == 0:
				isdiv = True
				break
		if isdiv:
			continue
		result[x] = 1
		for (d, v) in items:
			dx = d * x // gcd(d, x)
			if dx > limit:
				continue
			if dx not in result:
				result[dx] = 0
			result[dx] -= v
			if result[dx] == 0:
				del result[dx]
	return result

def sumProd(A, B):
	all = set()
	s = 0
	l = 0
	for x in range(A, 0, -1):
		process = getInterval(x, A + 1, A * B)
		for (d, v) in process.items():
			(sx0, lx0) = sumProdOneDivider(d, B * (x - 1))
			(sx1, lx1) = sumProdOneDivider(d, B * x)
			s += v * (sx1 - sx0)
			l += v * (lx1 - lx0)
	return (s, l)

def sumXor(A, B):
	if B < 100:
		return sumXorRef(A, B)
	b = B - 100
	s = b * (b + 1) // 2
	l = b + 1
	all = set()
	for x in range(1, A + 1):
		for y in range(b + 1, B + 1):
			xy = x ^ y
			if xy <= b:
				continue
			all.add(xy)
	s += sum(all)
	l += len(all)
	return (s, l)
(A, B) = map(int, input().split())
(prod, nprod) = sumProd(A, B)
(xor, nxor) = sumXor(A, B)
result = prod * nxor * pow(10, len('%d' % B) + 1) + nprod * xor
print(result)


def gcd(x, y):
	while y != 0:
		(x, y) = (y, x % y)
	return x

def sumProdRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x * y)
	return (sum(all), len(all))

def sumXorRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x ^ y)
	return (sum(all), len(all))

def sumProdOneDivider(divider, limit):
	count = limit // divider
	return (divider * (count + 1) * count // 2, count)

def get(result, x, limit):
	items = result.items()[:]
	if x not in result:
		result[x] = 0
	result[x] += 1
	if result[x] == 0:
		del result[x]
	for (d, v) in items:
		dx = d * x
		if dx > limit:
			continue
		if dx not in result:
			result[dx] = 0
		result[dx] -= v
		if result[dx] == 0:
			del result[dx]
	return result

def getInterval(start, finish, limit):
	result = {}
	for x in range(start, finish):
		items = list(result.items())[:]
		isdiv = False
		for d in range(start, x):
			if x % d == 0:
				isdiv = True
				break
		if isdiv:
			continue
		result[x] = 1
		for (d, v) in items:
			dx = d * x // gcd(d, x)
			if dx > limit:
				continue
			if dx not in result:
				result[dx] = 0
			result[dx] -= v
			if result[dx] == 0:
				del result[dx]
	return result

def sumProd(A, B):
	all = set()
	s = 0
	l = 0
	for x in range(A, 0, -1):
		process = getInterval(x, A + 1, A * B)
		for (d, v) in process.items():
			(sx0, lx0) = sumProdOneDivider(d, B * (x - 1))
			(sx1, lx1) = sumProdOneDivider(d, B * x)
			s += v * (sx1 - sx0)
			l += v * (lx1 - lx0)
	return (s, l)

def sumXor(A, B):
	if B < 100:
		return sumXorRef(A, B)
	b = B - 100
	s = b * (b + 1) // 2
	l = b + 1
	all = set()
	for x in range(1, A + 1):
		for y in range(b + 1, B + 1):
			xy = x ^ y
			if xy <= b:
				continue
			all.add(xy)
	s += sum(all)
	l += len(all)
	return (s, l)
(A, B) = map(int, input().split())
(prod, nprod) = sumProd(A, B)
(xor, nxor) = sumXor(A, B)
result = prod * nxor * pow(10, len('%d' % B) + 1) + nprod * xor
print(result)


def gcd(x, y):
	while y != 0:
		(x, y) = (y, x % y)
	return x

def sumProdRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x * y)
	return (sum(all), len(all))

def sumXorRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x ^ y)
	return (sum(all), len(all))

def sumProdOneDivider(divider, limit):
	count = limit // divider
	return (divider * (count + 1) * count // 2, count)

def get(result, x, limit):
	items = result.items()[:]
	if x not in result:
		result[x] = 0
	result[x] += 1
	if result[x] == 0:
		del result[x]
	for (d, v) in items:
		dx = d * x
		if dx > limit:
			continue
		if dx not in result:
			result[dx] = 0
		result[dx] -= v
		if result[dx] == 0:
			del result[dx]
	return result

def getInterval(start, finish, limit):
	result = {}
	for x in range(start, finish):
		items = list(result.items())[:]
		isdiv = False
		for d in range(start, x):
			if x % d == 0:
				isdiv = True
				break
		if isdiv:
			continue
		result[x] = 1
		for (d, v) in items:
			dx = d * x // gcd(d, x)
			if dx > limit:
				continue
			if dx not in result:
				result[dx] = 0
			result[dx] -= v
			if result[dx] == 0:
				del result[dx]
	return result

def sumProd(A, B):
	all = set()
	s = 0
	l = 0
	for x in range(A, 0, -1):
		process = getInterval(x, A + 1, A * B)
		for (d, v) in process.items():
			(sx0, lx0) = sumProdOneDivider(d, B * (x - 1))
			(sx1, lx1) = sumProdOneDivider(d, B * x)
			s += v * (sx1 - sx0)
			l += v * (lx1 - lx0)
	return (s, l)

def sumXor(A, B):
	if B < 100:
		return sumXorRef(A, B)
	b = B - 100
	s = b * (b + 1) // 2
	l = b + 1
	all = set()
	for x in range(1, A + 1):
		for y in range(b + 1, B + 1):
			xy = x ^ y
			if xy <= b:
				continue
			all.add(xy)
	s += sum(all)
	l += len(all)
	return (s, l)
(A, B) = map(int, input().split())
(prod, nprod) = sumProd(A, B)
(xor, nxor) = sumXor(A, B)
result = prod * nxor * pow(10, len('%d' % B) + 1) + nprod * xor
print(result)


def gcd(x, y):
	while y != 0:
		(x, y) = (y, x % y)
	return x

def sumProdRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x * y)
	return (sum(all), len(all))

def sumXorRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x ^ y)
	return (sum(all), len(all))

def sumProdOneDivider(divider, limit):
	count = limit // divider
	return (divider * (count + 1) * count // 2, count)

def get(result, x, limit):
	items = result.items()[:]
	if x not in result:
		result[x] = 0
	result[x] += 1
	if result[x] == 0:
		del result[x]
	for (d, v) in items:
		dx = d * x
		if dx > limit:
			continue
		if dx not in result:
			result[dx] = 0
		result[dx] -= v
		if result[dx] == 0:
			del result[dx]
	return result

def getInterval(start, finish, limit):
	result = {}
	for x in range(start, finish):
		items = list(result.items())[:]
		isdiv = False
		for d in range(start, x):
			if x % d == 0:
				isdiv = True
				break
		if isdiv:
			continue
		result[x] = 1
		for (d, v) in items:
			dx = d * x // gcd(d, x)
			if dx > limit:
				continue
			if dx not in result:
				result[dx] = 0
			result[dx] -= v
			if result[dx] == 0:
				del result[dx]
	return result

def sumProd(A, B):
	all = set()
	s = 0
	l = 0
	for x in range(A, 0, -1):
		process = getInterval(x, A + 1, A * B)
		for (d, v) in process.items():
			(sx0, lx0) = sumProdOneDivider(d, B * (x - 1))
			(sx1, lx1) = sumProdOneDivider(d, B * x)
			s += v * (sx1 - sx0)
			l += v * (lx1 - lx0)
	return (s, l)

def sumXor(A, B):
	if B < 100:
		return sumXorRef(A, B)
	b = B - 100
	s = b * (b + 1) // 2
	l = b + 1
	all = set()
	for x in range(1, A + 1):
		for y in range(b + 1, B + 1):
			xy = x ^ y
			if xy <= b:
				continue
			all.add(xy)
	s += sum(all)
	l += len(all)
	return (s, l)
(A, B) = map(int, input().split())
(prod, nprod) = sumProd(A, B)
(xor, nxor) = sumXor(A, B)
result = prod * nxor * pow(10, len('%d' % B) + 1) + nprod * xor
print(result)


def gcd(x, y):
	while y != 0:
		(x, y) = (y, x % y)
	return x

def sumProdRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x * y)
	return (sum(all), len(all))

def sumXorRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x ^ y)
	return (sum(all), len(all))

def sumProdOneDivider(divider, limit):
	count = limit // divider
	return (divider * (count + 1) * count // 2, count)

def get(result, x, limit):
	items = result.items()[:]
	if x not in result:
		result[x] = 0
	result[x] += 1
	if result[x] == 0:
		del result[x]
	for (d, v) in items:
		dx = d * x
		if dx > limit:
			continue
		if dx not in result:
			result[dx] = 0
		result[dx] -= v
		if result[dx] == 0:
			del result[dx]
	return result

def getInterval(start, finish, limit):
	result = {}
	for x in range(start, finish):
		items = list(result.items())[:]
		isdiv = False
		for d in range(start, x):
			if x % d == 0:
				isdiv = True
				break
		if isdiv:
			continue
		result[x] = 1
		for (d, v) in items:
			dx = d * x // gcd(d, x)
			if dx > limit:
				continue
			if dx not in result:
				result[dx] = 0
			result[dx] -= v
			if result[dx] == 0:
				del result[dx]
	return result

def sumProd(A, B):
	all = set()
	s = 0
	l = 0
	for x in range(A, 0, -1):
		process = getInterval(x, A + 1, A * B)
		for (d, v) in process.items():
			(sx0, lx0) = sumProdOneDivider(d, B * (x - 1))
			(sx1, lx1) = sumProdOneDivider(d, B * x)
			s += v * (sx1 - sx0)
			l += v * (lx1 - lx0)
	return (s, l)

def sumXor(A, B):
	if B < 100:
		return sumXorRef(A, B)
	b = B - 100
	s = b * (b + 1) // 2
	l = b + 1
	all = set()
	for x in range(1, A + 1):
		for y in range(b + 1, B + 1):
			xy = x ^ y
			if xy <= b:
				continue
			all.add(xy)
	s += sum(all)
	l += len(all)
	return (s, l)
(A, B) = map(int, input().split())
(prod, nprod) = sumProd(A, B)
(xor, nxor) = sumXor(A, B)
result = prod * nxor * pow(10, len('%d' % B) + 1) + nprod * xor
print(result)


def gcd(x, y):
	while y != 0:
		(x, y) = (y, x % y)
	return x

def sumProdRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x * y)
	return (sum(all), len(all))

def sumXorRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x ^ y)
	return (sum(all), len(all))

def sumProdOneDivider(divider, limit):
	count = limit // divider
	return (divider * (count + 1) * count // 2, count)

def get(result, x, limit):
	items = result.items()[:]
	if x not in result:
		result[x] = 0
	result[x] += 1
	if result[x] == 0:
		del result[x]
	for (d, v) in items:
		dx = d * x
		if dx > limit:
			continue
		if dx not in result:
			result[dx] = 0
		result[dx] -= v
		if result[dx] == 0:
			del result[dx]
	return result

def getInterval(start, finish, limit):
	result = {}
	for x in range(start, finish):
		items = list(result.items())[:]
		isdiv = False
		for d in range(start, x):
			if x % d == 0:
				isdiv = True
				break
		if isdiv:
			continue
		result[x] = 1
		for (d, v) in items:
			dx = d * x // gcd(d, x)
			if dx > limit:
				continue
			if dx not in result:
				result[dx] = 0
			result[dx] -= v
			if result[dx] == 0:
				del result[dx]
	return result

def sumProd(A, B):
	all = set()
	s = 0
	l = 0
	for x in range(A, 0, -1):
		process = getInterval(x, A + 1, A * B)
		for (d, v) in process.items():
			(sx0, lx0) = sumProdOneDivider(d, B * (x - 1))
			(sx1, lx1) = sumProdOneDivider(d, B * x)
			s += v * (sx1 - sx0)
			l += v * (lx1 - lx0)
	return (s, l)

def sumXor(A, B):
	if B < 100:
		return sumXorRef(A, B)
	b = B - 100
	s = b * (b + 1) // 2
	l = b + 1
	all = set()
	for x in range(1, A + 1):
		for y in range(b + 1, B + 1):
			xy = x ^ y
			if xy <= b:
				continue
			all.add(xy)
	s += sum(all)
	l += len(all)
	return (s, l)
(A, B) = map(int, input().split())
(prod, nprod) = sumProd(A, B)
(xor, nxor) = sumXor(A, B)
result = prod * nxor * pow(10, len('%d' % B) + 1) + nprod * xor
print(result)


def gcd(x, y):
	while y != 0:
		(x, y) = (y, x % y)
	return x

def sumProdRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x * y)
	return (sum(all), len(all))

def sumXorRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x ^ y)
	return (sum(all), len(all))

def sumProdOneDivider(divider, limit):
	count = limit // divider
	return (divider * (count + 1) * count // 2, count)

def get(result, x, limit):
	items = result.items()[:]
	if x not in result:
		result[x] = 0
	result[x] += 1
	if result[x] == 0:
		del result[x]
	for (d, v) in items:
		dx = d * x
		if dx > limit:
			continue
		if dx not in result:
			result[dx] = 0
		result[dx] -= v
		if result[dx] == 0:
			del result[dx]
	return result

def getInterval(start, finish, limit):
	result = {}
	for x in range(start, finish):
		items = list(result.items())[:]
		isdiv = False
		for d in range(start, x):
			if x % d == 0:
				isdiv = True
				break
		if isdiv:
			continue
		result[x] = 1
		for (d, v) in items:
			dx = d * x // gcd(d, x)
			if dx > limit:
				continue
			if dx not in result:
				result[dx] = 0
			result[dx] -= v
			if result[dx] == 0:
				del result[dx]
	return result

def sumProd(A, B):
	all = set()
	s = 0
	l = 0
	for x in range(A, 0, -1):
		process = getInterval(x, A + 1, A * B)
		for (d, v) in process.items():
			(sx0, lx0) = sumProdOneDivider(d, B * (x - 1))
			(sx1, lx1) = sumProdOneDivider(d, B * x)
			s += v * (sx1 - sx0)
			l += v * (lx1 - lx0)
	return (s, l)

def sumXor(A, B):
	if B < 100:
		return sumXorRef(A, B)
	b = B - 100
	s = b * (b + 1) // 2
	l = b + 1
	all = set()
	for x in range(1, A + 1):
		for y in range(b + 1, B + 1):
			xy = x ^ y
			if xy <= b:
				continue
			all.add(xy)
	s += sum(all)
	l += len(all)
	return (s, l)
(A, B) = map(int, input().split())
(prod, nprod) = sumProd(A, B)
(xor, nxor) = sumXor(A, B)
result = prod * nxor * pow(10, len('%d' % B) + 1) + nprod * xor
print(result)


def gcd(x, y):
	while y != 0:
		(x, y) = (y, x % y)
	return x

def sumProdRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x * y)
	return (sum(all), len(all))

def sumXorRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x ^ y)
	return (sum(all), len(all))

def sumProdOneDivider(divider, limit):
	count = limit // divider
	return (divider * (count + 1) * count // 2, count)

def get(result, x, limit):
	items = result.items()[:]
	if x not in result:
		result[x] = 0
	result[x] += 1
	if result[x] == 0:
		del result[x]
	for (d, v) in items:
		dx = d * x
		if dx > limit:
			continue
		if dx not in result:
			result[dx] = 0
		result[dx] -= v
		if result[dx] == 0:
			del result[dx]
	return result

def getInterval(start, finish, limit):
	result = {}
	for x in range(start, finish):
		items = list(result.items())[:]
		isdiv = False
		for d in range(start, x):
			if x % d == 0:
				isdiv = True
				break
		if isdiv:
			continue
		result[x] = 1
		for (d, v) in items:
			dx = d * x // gcd(d, x)
			if dx > limit:
				continue
			if dx not in result:
				result[dx] = 0
			result[dx] -= v
			if result[dx] == 0:
				del result[dx]
	return result

def sumProd(A, B):
	all = set()
	s = 0
	l = 0
	for x in range(A, 0, -1):
		process = getInterval(x, A + 1, A * B)
		for (d, v) in process.items():
			(sx0, lx0) = sumProdOneDivider(d, B * (x - 1))
			(sx1, lx1) = sumProdOneDivider(d, B * x)
			s += v * (sx1 - sx0)
			l += v * (lx1 - lx0)
	return (s, l)

def sumXor(A, B):
	if B < 100:
		return sumXorRef(A, B)
	b = B - 100
	s = b * (b + 1) // 2
	l = b + 1
	all = set()
	for x in range(1, A + 1):
		for y in range(b + 1, B + 1):
			xy = x ^ y
			if xy <= b:
				continue
			all.add(xy)
	s += sum(all)
	l += len(all)
	return (s, l)
(A, B) = map(int, input().split())
(prod, nprod) = sumProd(A, B)
(xor, nxor) = sumXor(A, B)
result = prod * nxor * pow(10, len('%d' % B) + 1) + nprod * xor
print(result)


def gcd(x, y):
	while y != 0:
		(x, y) = (y, x % y)
	return x

def sumProdRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x * y)
	return (sum(all), len(all))

def sumXorRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x ^ y)
	return (sum(all), len(all))

def sumProdOneDivider(divider, limit):
	count = limit // divider
	return (divider * (count + 1) * count // 2, count)

def get(result, x, limit):
	items = result.items()[:]
	if x not in result:
		result[x] = 0
	result[x] += 1
	if result[x] == 0:
		del result[x]
	for (d, v) in items:
		dx = d * x
		if dx > limit:
			continue
		if dx not in result:
			result[dx] = 0
		result[dx] -= v
		if result[dx] == 0:
			del result[dx]
	return result

def getInterval(start, finish, limit):
	result = {}
	for x in range(start, finish):
		items = list(result.items())[:]
		isdiv = False
		for d in range(start, x):
			if x % d == 0:
				isdiv = True
				break
		if isdiv:
			continue
		result[x] = 1
		for (d, v) in items:
			dx = d * x // gcd(d, x)
			if dx > limit:
				continue
			if dx not in result:
				result[dx] = 0
			result[dx] -= v
			if result[dx] == 0:
				del result[dx]
	return result

def sumProd(A, B):
	all = set()
	s = 0
	l = 0
	for x in range(A, 0, -1):
		process = getInterval(x, A + 1, A * B)
		for (d, v) in process.items():
			(sx0, lx0) = sumProdOneDivider(d, B * (x - 1))
			(sx1, lx1) = sumProdOneDivider(d, B * x)
			s += v * (sx1 - sx0)
			l += v * (lx1 - lx0)
	return (s, l)

def sumXor(A, B):
	if B < 100:
		return sumXorRef(A, B)
	b = B - 100
	s = b * (b + 1) // 2
	l = b + 1
	all = set()
	for x in range(1, A + 1):
		for y in range(b + 1, B + 1):
			xy = x ^ y
			if xy <= b:
				continue
			all.add(xy)
	s += sum(all)
	l += len(all)
	return (s, l)
(A, B) = map(int, input().split())
(prod, nprod) = sumProd(A, B)
(xor, nxor) = sumXor(A, B)
result = prod * nxor * pow(10, len('%d' % B) + 1) + nprod * xor
print(result)


def gcd(x, y):
	while y != 0:
		(x, y) = (y, x % y)
	return x

def sumProdRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x * y)
	return (sum(all), len(all))

def sumXorRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x ^ y)
	return (sum(all), len(all))

def sumProdOneDivider(divider, limit):
	count = limit // divider
	return (divider * (count + 1) * count // 2, count)

def get(result, x, limit):
	items = result.items()[:]
	if x not in result:
		result[x] = 0
	result[x] += 1
	if result[x] == 0:
		del result[x]
	for (d, v) in items:
		dx = d * x
		if dx > limit:
			continue
		if dx not in result:
			result[dx] = 0
		result[dx] -= v
		if result[dx] == 0:
			del result[dx]
	return result

def getInterval(start, finish, limit):
	result = {}
	for x in range(start, finish):
		items = list(result.items())[:]
		isdiv = False
		for d in range(start, x):
			if x % d == 0:
				isdiv = True
				break
		if isdiv:
			continue
		result[x] = 1
		for (d, v) in items:
			dx = d * x // gcd(d, x)
			if dx > limit:
				continue
			if dx not in result:
				result[dx] = 0
			result[dx] -= v
			if result[dx] == 0:
				del result[dx]
	return result

def sumProd(A, B):
	all = set()
	s = 0
	l = 0
	for x in range(A, 0, -1):
		process = getInterval(x, A + 1, A * B)
		for (d, v) in process.items():
			(sx0, lx0) = sumProdOneDivider(d, B * (x - 1))
			(sx1, lx1) = sumProdOneDivider(d, B * x)
			s += v * (sx1 - sx0)
			l += v * (lx1 - lx0)
	return (s, l)

def sumXor(A, B):
	if B < 100:
		return sumXorRef(A, B)
	b = B - 100
	s = b * (b + 1) // 2
	l = b + 1
	all = set()
	for x in range(1, A + 1):
		for y in range(b + 1, B + 1):
			xy = x ^ y
			if xy <= b:
				continue
			all.add(xy)
	s += sum(all)
	l += len(all)
	return (s, l)
(A, B) = map(int, input().split())
(prod, nprod) = sumProd(A, B)
(xor, nxor) = sumXor(A, B)
result = prod * nxor * pow(10, len('%d' % B) + 1) + nprod * xor
print(result)


def gcd(x, y):
	while y != 0:
		(x, y) = (y, x % y)
	return x

def sumProdRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x * y)
	return (sum(all), len(all))

def sumXorRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x ^ y)
	return (sum(all), len(all))

def sumProdOneDivider(divider, limit):
	count = limit // divider
	return (divider * (count + 1) * count // 2, count)

def get(result, x, limit):
	items = result.items()[:]
	if x not in result:
		result[x] = 0
	result[x] += 1
	if result[x] == 0:
		del result[x]
	for (d, v) in items:
		dx = d * x
		if dx > limit:
			continue
		if dx not in result:
			result[dx] = 0
		result[dx] -= v
		if result[dx] == 0:
			del result[dx]
	return result

def getInterval(start, finish, limit):
	result = {}
	for x in range(start, finish):
		items = list(result.items())[:]
		isdiv = False
		for d in range(start, x):
			if x % d == 0:
				isdiv = True
				break
		if isdiv:
			continue
		result[x] = 1
		for (d, v) in items:
			dx = d * x // gcd(d, x)
			if dx > limit:
				continue
			if dx not in result:
				result[dx] = 0
			result[dx] -= v
			if result[dx] == 0:
				del result[dx]
	return result

def sumProd(A, B):
	all = set()
	s = 0
	l = 0
	for x in range(A, 0, -1):
		process = getInterval(x, A + 1, A * B)
		for (d, v) in process.items():
			(sx0, lx0) = sumProdOneDivider(d, B * (x - 1))
			(sx1, lx1) = sumProdOneDivider(d, B * x)
			s += v * (sx1 - sx0)
			l += v * (lx1 - lx0)
	return (s, l)

def sumXor(A, B):
	if B < 100:
		return sumXorRef(A, B)
	b = B - 100
	s = b * (b + 1) // 2
	l = b + 1
	all = set()
	for x in range(1, A + 1):
		for y in range(b + 1, B + 1):
			xy = x ^ y
			if xy <= b:
				continue
			all.add(xy)
	s += sum(all)
	l += len(all)
	return (s, l)
(A, B) = map(int, input().split())
(prod, nprod) = sumProd(A, B)
(xor, nxor) = sumXor(A, B)
result = prod * nxor * pow(10, len('%d' % B) + 1) + nprod * xor
print(result)


def gcd(x, y):
	while y != 0:
		(x, y) = (y, x % y)
	return x

def sumProdRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x * y)
	return (sum(all), len(all))

def sumXorRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x ^ y)
	return (sum(all), len(all))

def sumProdOneDivider(divider, limit):
	count = limit // divider
	return (divider * (count + 1) * count // 2, count)

def get(result, x, limit):
	items = result.items()[:]
	if x not in result:
		result[x] = 0
	result[x] += 1
	if result[x] == 0:
		del result[x]
	for (d, v) in items:
		dx = d * x
		if dx > limit:
			continue
		if dx not in result:
			result[dx] = 0
		result[dx] -= v
		if result[dx] == 0:
			del result[dx]
	return result

def getInterval(start, finish, limit):
	result = {}
	for x in range(start, finish):
		items = list(result.items())[:]
		isdiv = False
		for d in range(start, x):
			if x % d == 0:
				isdiv = True
				break
		if isdiv:
			continue
		result[x] = 1
		for (d, v) in items:
			dx = d * x // gcd(d, x)
			if dx > limit:
				continue
			if dx not in result:
				result[dx] = 0
			result[dx] -= v
			if result[dx] == 0:
				del result[dx]
	return result

def sumProd(A, B):
	all = set()
	s = 0
	l = 0
	for x in range(A, 0, -1):
		process = getInterval(x, A + 1, A * B)
		for (d, v) in process.items():
			(sx0, lx0) = sumProdOneDivider(d, B * (x - 1))
			(sx1, lx1) = sumProdOneDivider(d, B * x)
			s += v * (sx1 - sx0)
			l += v * (lx1 - lx0)
	return (s, l)

def sumXor(A, B):
	if B < 100:
		return sumXorRef(A, B)
	b = B - 100
	s = b * (b + 1) // 2
	l = b + 1
	all = set()
	for x in range(1, A + 1):
		for y in range(b + 1, B + 1):
			xy = x ^ y
			if xy <= b:
				continue
			all.add(xy)
	s += sum(all)
	l += len(all)
	return (s, l)
(A, B) = map(int, input().split())
(prod, nprod) = sumProd(A, B)
(xor, nxor) = sumXor(A, B)
result = prod * nxor * pow(10, len('%d' % B) + 1) + nprod * xor
print(result)


def gcd(x, y):
	while y != 0:
		(x, y) = (y, x % y)
	return x

def sumProdRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x * y)
	return (sum(all), len(all))

def sumXorRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x ^ y)
	return (sum(all), len(all))

def sumProdOneDivider(divider, limit):
	count = limit // divider
	return (divider * (count + 1) * count // 2, count)

def get(result, x, limit):
	items = result.items()[:]
	if x not in result:
		result[x] = 0
	result[x] += 1
	if result[x] == 0:
		del result[x]
	for (d, v) in items:
		dx = d * x
		if dx > limit:
			continue
		if dx not in result:
			result[dx] = 0
		result[dx] -= v
		if result[dx] == 0:
			del result[dx]
	return result

def getInterval(start, finish, limit):
	result = {}
	for x in range(start, finish):
		items = list(result.items())[:]
		isdiv = False
		for d in range(start, x):
			if x % d == 0:
				isdiv = True
				break
		if isdiv:
			continue
		result[x] = 1
		for (d, v) in items:
			dx = d * x // gcd(d, x)
			if dx > limit:
				continue
			if dx not in result:
				result[dx] = 0
			result[dx] -= v
			if result[dx] == 0:
				del result[dx]
	return result

def sumProd(A, B):
	all = set()
	s = 0
	l = 0
	for x in range(A, 0, -1):
		process = getInterval(x, A + 1, A * B)
		for (d, v) in process.items():
			(sx0, lx0) = sumProdOneDivider(d, B * (x - 1))
			(sx1, lx1) = sumProdOneDivider(d, B * x)
			s += v * (sx1 - sx0)
			l += v * (lx1 - lx0)
	return (s, l)

def sumXor(A, B):
	if B < 100:
		return sumXorRef(A, B)
	b = B - 100
	s = b * (b + 1) // 2
	l = b + 1
	all = set()
	for x in range(1, A + 1):
		for y in range(b + 1, B + 1):
			xy = x ^ y
			if xy <= b:
				continue
			all.add(xy)
	s += sum(all)
	l += len(all)
	return (s, l)
(A, B) = map(int, input().split())
(prod, nprod) = sumProd(A, B)
(xor, nxor) = sumXor(A, B)
result = prod * nxor * pow(10, len('%d' % B) + 1) + nprod * xor
print(result)


def gcd(x, y):
	while y != 0:
		(x, y) = (y, x % y)
	return x

def sumProdRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x * y)
	return (sum(all), len(all))

def sumXorRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x ^ y)
	return (sum(all), len(all))

def sumProdOneDivider(divider, limit):
	count = limit // divider
	return (divider * (count + 1) * count // 2, count)

def get(result, x, limit):
	items = result.items()[:]
	if x not in result:
		result[x] = 0
	result[x] += 1
	if result[x] == 0:
		del result[x]
	for (d, v) in items:
		dx = d * x
		if dx > limit:
			continue
		if dx not in result:
			result[dx] = 0
		result[dx] -= v
		if result[dx] == 0:
			del result[dx]
	return result

def getInterval(start, finish, limit):
	result = {}
	for x in range(start, finish):
		items = list(result.items())[:]
		isdiv = False
		for d in range(start, x):
			if x % d == 0:
				isdiv = True
				break
		if isdiv:
			continue
		result[x] = 1
		for (d, v) in items:
			dx = d * x // gcd(d, x)
			if dx > limit:
				continue
			if dx not in result:
				result[dx] = 0
			result[dx] -= v
			if result[dx] == 0:
				del result[dx]
	return result

def sumProd(A, B):
	all = set()
	s = 0
	l = 0
	for x in range(A, 0, -1):
		process = getInterval(x, A + 1, A * B)
		for (d, v) in process.items():
			(sx0, lx0) = sumProdOneDivider(d, B * (x - 1))
			(sx1, lx1) = sumProdOneDivider(d, B * x)
			s += v * (sx1 - sx0)
			l += v * (lx1 - lx0)
	return (s, l)

def sumXor(A, B):
	if B < 100:
		return sumXorRef(A, B)
	b = B - 100
	s = b * (b + 1) // 2
	l = b + 1
	all = set()
	for x in range(1, A + 1):
		for y in range(b + 1, B + 1):
			xy = x ^ y
			if xy <= b:
				continue
			all.add(xy)
	s += sum(all)
	l += len(all)
	return (s, l)
(A, B) = map(int, input().split())
(prod, nprod) = sumProd(A, B)
(xor, nxor) = sumXor(A, B)
result = prod * nxor * pow(10, len('%d' % B) + 1) + nprod * xor
print(result)


def gcd(x, y):
	while y != 0:
		(x, y) = (y, x % y)
	return x

def sumProdRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x * y)
	return (sum(all), len(all))

def sumXorRef(A, B):
	all = set()
	for x in range(1, A + 1):
		for y in range(1, B + 1):
			all.add(x ^ y)
	return (sum(all), len(all))

def sumProdOneDivider(divider, limit):
	count = limit // divider
	return (divider * (count + 1) * count // 2, count)

def get(result, x, limit):
	items = result.items()[:]
	if x not in result:
		result[x] = 0
	result[x] += 1
	if result[x] == 0:
		del result[x]
	for (d, v) in items:
		dx = d * x
		if dx > limit:
			continue
		if dx not in result:
			result[dx] = 0
		result[dx] -= v
		if result[dx] == 0:
			del result[dx]
	return result

def getInterval(start, finish, limit):
	result = {}
	for x in range(start, finish):
		items = list(result.items())[:]
		isdiv = False
		for d in range(start, x):
			if x % d == 0:
				isdiv = True
				break
		if isdiv:
			continue
		result[x] = 1
		for (d, v) in items:
			dx = d * x // gcd(d, x)
			if dx > limit:
				continue
			if dx not in result:
				result[dx] = 0
			result[dx] -= v
			if result[dx] == 0:
				del result[dx]
	return result

def sumProd(A, B):
	all = set()
	s = 0
	l = 0
	for x in range(A, 0, -1):
		process = getInterval(x, A + 1, A * B)
		for (d, v) in process.items():
			(sx0, lx0) = sumProdOneDivider(d, B * (x - 1))
			(sx1, lx1) = sumProdOneDivider(d, B * x)
			s += v * (sx1 - sx0)
			l += v * (lx1 - lx0)
	return (s, l)

def sumXor(A, B):
	if B < 100:
		return sumXorRef(A, B)
	b = B - 100
	s = b * (b + 1) // 2
	l = b + 1
	all = set()
	for x in range(1, A + 1):
		for y in range(b + 1, B + 1):
			xy = x ^ y
			if xy <= b:
				continue
			all.add(xy)
	s += sum(all)
	l += len(all)
	return (s, l)
(A, B) = map(int, input().split())
(prod, nprod) = sumProd(A, B)
(xor, nxor) = sumXor(A, B)
result = prod * nxor * pow(10, len('%d' % B) + 1) + nprod * xor
print(result)