Maxim wants to buy an apartment in a new house at Line Avenue of Metropolis. The house has n apartments that are numbered from 1 to n and are arranged in a row. Two apartments are adjacent if their indices differ by 1. Some of the apartments can already be inhabited, others are available for sale.

Maxim often visits his neighbors, so apartment is good for him if it is available for sale and there is at least one already inhabited apartment adjacent to it. Maxim knows that there are exactly k already inhabited apartments, but he doesn't know their indices yet.

Find out what could be the minimum possible and the maximum possible number of apartments that are good for Maxim.


-----Input-----

The only line of the input contains two integers: n and k (1 ≤ n ≤ 10^9, 0 ≤ k ≤ n).


-----Output-----

Print the minimum possible and the maximum possible number of apartments good for Maxim.


-----Example-----
Input
6 3

Output
1 3



-----Note-----

In the sample test, the number of good apartments could be minimum possible if, for example, apartments with indices 1, 2 and 3 were inhabited. In this case only apartment 4 is good. The maximum possible number could be, for example, if apartments with indices 1, 3 and 5 were inhabited. In this case all other apartments: 2, 4 and 6 are good.

Difficulty: EASY
Tags: Mathematics

Constructive algorithms

Starter code:

Solutions:
ipt = input().split()
(n, k) = (int(ipt[0]), int(ipt[1]))

def mini(all, taken):
	if taken + 1 <= all and (not taken == 0):
		return 1
	else:
		return 0

def maxi(all, taken):
	if taken >= all / 2:
		return all - taken
	elif taken < all / 2:
		maximum = 2 * taken
		while maximum > all:
			maximum -= 1
		if maximum > all - taken:
			maximum = all - taken
		return maximum
print(str(mini(n, k)) + ' ' + str(maxi(n, k)))


(n, k) = map(int, input().split())
if k == 0 or k == n:
	print('0 0')
elif 3 * k <= n:
	print(f'1 {2 * k}')
else:
	print(f'1 {n - k}')


(n, k) = map(int, input().split(' '))
print(min(1, k, n - k), min(n - k, 2 * k))


(n, k) = [int(f) for f in input().split(' ') if f]
blocks = (n + 2) // 3
if k == 0:
	print(0, 0)
	exit()
if blocks > k:
	print([0, 1][k + 1 <= n], 2 * k)
else:
	spaces = 2 * blocks
	leftToArrange = max(0, k - blocks - (n - blocks * 3))
	print([0, 1][k + 1 <= n], max([0, 1][k + 1 <= n], spaces - leftToArrange))


(n, k) = list(map(int, input().split()))
(ans1, ans2) = (0, 0)
if k != 0 and k != n:
	ans1 = 1
if 3 * k < n:
	ans2 = 2 * k
else:
	ans2 = n - k
print(ans1, ans2)


from math import ceil
(n, k) = list(map(int, input().split()))
if k > 0 and k < n:
	ans1 = 1
else:
	ans1 = 0
if k >= ceil(n / 3):
	ans2 = n - k
else:
	ans2 = 2 * k
print(ans1, ans2)


nk = input().split()
n = int(nk[0])
k = int(nk[1])
if k == n or k == 0:
	L = [0, 0]
else:
	L = [1, 0]
	if k > n // 3:
		L[1] = n - k
	else:
		L[1] = 2 * k
print(*L)


(n, k) = tuple((int(x) for x in input().split()))
maximum = 0
minimum = 0
if k == 0:
	print(minimum, maximum)
	exit()
if k >= n:
	print(minimum, maximum)
else:
	minimum = 1
	maximum = min(2 * k, n - k)
	print(minimum, maximum)


(n, k) = map(int, input().split())
maximum = min(k * 2, n - k)
if k == 0 or k == n:
	minimum = 0
else:
	minimum = 1
print(minimum, maximum)


(n, k) = map(int, input().split())
a = 1 if k and k < n else 0
b = 2 * k if k <= n // 3 else n - k
print(a, b)


(n, k) = map(int, input().split())
mn = 0 if k == 0 or k == n else 1
mx = 2 * k
if 3 * k > n:
	(a, b) = (n // 3, n % 3)
	good = 2 * a + 1 if b == 2 else 2 * a
	k = k - a if b == 0 else k - a - 1
	mx = good - k
print(mn, mx)


from sys import stdin

def get_ints():
	return list(map(int, stdin.readline().strip().split()))
res = []
(n, k) = get_ints()
if n == k or k == 0:
	res.append(0)
else:
	res.append(1)
res.append(k * 2 if k <= n / 3 else n - k)
print(' '.join([str(x) for x in res]))


(n, k) = [int(i) for i in input().split()]
if n - k > 0 and k != 0:
	if 2 * k >= n - k:
		print('1 ', n - k)
	else:
		print('1 ', 2 * k)
else:
	print('0 0')


(n, k) = map(int, input().split())
if n == k:
	print(0, 0)
	exit()
t = n // 3
if n == 2 and k == 1:
	print(1, 1)
	exit()
if n == 2 and k == 0:
	print(0, 0)
	exit()
if k > 0:
	print(1, end=' ')
else:
	print(0, end=' ')
if k <= t + n % 3:
	if k <= t:
		print(2 * k)
	elif k >= t and k <= t + n % 3:
		print(2 * t + n % 3 - 1)
elif k < n // 2:
	print(2 * t + n % 3 - (k - t))
else:
	print(n - k)


(n, k) = map(int, input().split())
if n == k:
	print(0, 0)
elif k == 0:
	print(0, 0)
elif 2 * k >= n:
	print(1, n - k)
elif n // 3 < k <= n // 2:
	print(1, n - k)
elif k <= n // 3:
	print(1, 2 * k)


(n, k) = map(int, input().split())
if k == 0:
	min = 0
	max = 0
elif k == n:
	min = 0
	max = 0
elif n // k > 2 and n // k < 3:
	min = 1
	max = k + 1
elif n // k >= 3:
	min = 1
	max = k * 2
else:
	min = 1
	max = n - k
print(min, max)


(n, k) = map(int, input().split())
if k == 0:
	print(0, 0)
else:
	print(min(n - k, 1), min((k - 1) * 2 + 2, n - k))


from itertools import permutations
(m, n) = map(int, input().split())
if m <= n or n == 0:
	print('0 0')
elif n <= m // 3:
	s = 2 * n
	print('1', s)
else:
	s = m - n
	print('1', s)


(n, k) = map(int, input().split())
low = -1
high = -1
if k == 0:
	low = 0
	high = 0
elif k == n:
	low = 0
	high = 0
else:
	low = 1
	if n >= 3 * k:
		high = 2 * k
	else:
		high = n - k
print(low, high)


(n, m) = map(int, input().split(' '))
r = 0
if n - m >= 1:
	r = 1
if m == 0:
	print('0 0')
elif m <= n // 3:
	print(r, m * 2)
else:
	print(r, n - m)


(n, m) = map(int, input().split())
if m <= 0 or m >= n:
	a = 0
else:
	a = 1
b = 0
if m > 0:
	if m * 2 <= n:
		if n % 2 == 0 and m >= n // 2:
			b = max(b, m)
		else:
			b = max(b, m + 1)
	else:
		b = max(b, n - n // 2 - (m - n // 2))
	if m * 3 <= n:
		b = max(b, m * 2)
	else:
		b = max(b, n // 3 * 2 - (m - n // 3 - n % 3))
print(a, b)


import sys
import os
import math
import re
(n, k) = map(int, input().split())
minP = 1
maxP = 0
inhabited = 0
opt = [2, 5, 8]
if k == n or k == 0:
	minP = 0
	maxP = 0
maxP = min(2 * k, n - k)
print(minP, maxP)


(n, k) = map(int, input().split())
if k == 0 or k == n:
	print(0, 0)
else:
	c = n // 3
	m = n % 3
	if c >= k:
		print(1, k * 2)
	else:
		ans = c * 2
		if m == 2:
			ans += 1
			k -= 1
		elif m == 1:
			k -= 1
		ans -= k - c
		print(1, ans)


(n, k) = map(int, input().split())
if k == 0:
	print(0, 0)
	exit()
x = min(n - k, 1)
y = min(n - k, 2 * k)
print(x, y)


from sys import stdin, stdout
(n, k) = map(int, stdin.readline().rstrip().split())
minH = min([1, k, n - k])
maxH = min([2 * k, n - k])
print(str(minH) + ' ' + str(maxH))


(a, b) = map(int, input().split())
if b == 0:
	print(0, 0)
	exit()
print(min(1, a - b), min(2 * b, a - b))


a = input().split()
n = int(a[0])
k = int(a[1])
print(int(k < n and k != 0), end=' ')
print(min(n - k, k * 2))


(n, k) = map(int, input().split())
if k == 0 or k == n:
	print(0, end=' ')
else:
	print(1, end=' ')
if 3 * k <= n:
	print(2 * k)
else:
	print(n - k)


(n, k) = list(map(int, input().split()))
minv = 1
maxv = 1
if k == 0 or k == n:
	minv = 0
maxv = min(k * 2, n - k)
print(minv, maxv)


(n, k) = map(int, input().split())
(mini, maxi) = (0, 0)
if n > k and k != 0:
	mini = 1
else:
	mini = 0
if n > 3 * k:
	maxi = 2 * k
else:
	maxi = n - k
print(mini, maxi)


(n, k) = (int(x) for x in input().split())
min_safe = int(k > 0 and k < n)
max_safe = 2 * k if 3 * k <= n else n - k
print(min_safe, max_safe)


t = [int(i) for i in input().split()]
(n, k) = (t[0], t[1])
print(1 if n - k != 0 and k != 0 else 0, n - k - (n - 3 * k if n - 3 * k > 0 else 0))


(n, k) = list(map(int, input().split()))
mn = 1 if 0 < k < n else 0
mx = min(2 * k, n - k)
print(mn, mx)


(n, k) = map(int, input().split())
if k == n or k == 0:
	a = 0
else:
	a = 1
b = 0
if n == k or k == 0:
	b = 0
else:
	b = min(n // 3, k) * 2
	k -= min(n // 3, k)
	if k != 0:
		if n % 3 == 1:
			k -= 1
		elif n % 3 == 2:
			k -= 1
			b += 1
	b -= k
print(a, b)


(apartments_nr, neighbours_nr) = (int(x) for x in input().split())
min_ans = int(apartments_nr != neighbours_nr)
if neighbours_nr == 0:
	min_ans = 0
max_ans = min(2 * neighbours_nr, apartments_nr - neighbours_nr)
print(min_ans, max_ans)


def list_input():
	return list(map(int, input().split()))

def map_input():
	return list(map(int, input().split()))

def map_string():
	return input().split()
(n, k) = map_input()
a = -1
b = -1
if k == 0 or k == n:
	a = 0
	b = 0
else:
	a = 1
	b = n - k
	b = min(b, k * 2)
print(a, b)


(n, k) = map(int, input().split())
ans = 0
anss = 1
if n == k or k == 0:
	anss = 0
	ans = 0
elif 3 * k <= n:
	anss = 1
	ans = 2 * k
else:
	anss = 1
	ans = n - k
print(anss, ans)


(apts, neighbors) = [int(a) for a in input().strip().split()]
minimum = 1
if neighbors == 0:
	minimum = 0
if apts == neighbors:
	minimum = 0
empty = apts - neighbors
if neighbors * 2 < empty:
	maximum = neighbors * 2
else:
	maximum = empty
print(minimum, maximum)


def func(a, b):
	if a < b:
		return a
	else:
		return b
(a, b) = map(int, input().split())
if b == 0:
	print('0 0\n')
elif a == b:
	print('0 0\n')
else:
	print('1', func(b * 2, a - b))


(n, k) = map(int, input().split())
if n == k or k == 0:
	ansM = 0
else:
	ansM = 1
ansMx = min(n - k, 2 * k)
print(str(ansM) + ' ' + str(ansMx))


(n, k) = [int(x) for x in input().split()]
if k > 0 and k < n:
	v_min = 1
else:
	v_min = 0
if 3 * k < n:
	v_max = 2 * k
else:
	v_max = n - k
print('{} {}'.format(v_min, v_max))


def solution(n, k):
	if k == 0 or k == n:
		return (0, 0)
	if 3 * k < n:
		max_ans = 2 * k
	else:
		max_ans = n - k
	return (1, max_ans)
(n, k) = map(int, input().split())
print(*solution(n, k))


A = input().split()
n = int(A[0])
k = int(A[1])
if k != 0 and k != n:
	if k * 3 <= n:
		print(1, k * 2)
	else:
		print(1, n - k)
else:
	print(0, 0)


(n, k) = tuple(map(int, input().split()))
mn = lambda n, k: 0 if n == k or k == 0 else 1

def mx(n, k):
	s = n // 3
	r = n % 3
	if k > s:
		return s * 2 - (k - s) + r
	return k * 2
print(mn(n, k), mx(n, k))


(n, k) = map(int, input().split())
print(min(int(bool(k)), n - k), min(n - k, 2 * k))


def main():
	(n, k) = list(map(int, list(input().split())))
	_min = 0
	_max = 0
	if k == n or k == 0:
		print(0, 0)
		return
	_min = 1
	if n <= 3 * k:
		_max = n - k
	else:
		_max = k * 2
	print(_min, _max)
main()


(n, k) = map(int, input().split())
if k == 0 or k == n:
	mn = 0
else:
	mn = 1
if 3 * k <= n:
	mx = 2 * k
else:
	mx = n - k
print(mn, mx)


s = input().split(' ')
n = int(s[0])
k = int(s[1])
(least, greatest) = (0, 0)
if k == 0 or k == n:
	print(0, 0)
elif k * 3 > n:
	print(1, n - k)
else:
	print(1, k * 2)


def main():
	(n, k) = [int(x) for x in input().strip().split()]
	minimum = min([n - k, 1, k])
	maximum = min(n - k, 2 * k)
	print(minimum, maximum)
main()


(n, k) = map(int, input().split())
k2 = k
mn = 1 if k < n else 0
temp = n // 3
mx = 0
if temp <= k:
	mx += temp * 2
	k -= temp
else:
	mx += k * 2
	k = 0
if n % 3 == 1:
	if k > 0:
		k -= 1
if n % 3 == 2:
	if k > 0:
		mx += 1
		k -= 1
mx -= k
if k2 == 0:
	print(0, 0)
else:
	print(mn, mx)


(n, k) = map(int, input().split())
first = min(1, n - k)
second = min(2 * k, n - k)
if k == 0:
	print('0 0')
else:
	print('{} {}'.format(first, second))


(n, k) = [int(i) for i in input().split()]
i = 0
cntmin = 0
cntmax = 0
cnt = 0
if n == k or n == 0 or k == 0:
	cntmin = 0
else:
	cntmin = 1
if 3 * k - 1 < n:
	cntmax = 2 * k
elif 3 * k - 1 == n:
	cntmax = 2 * k - 1
else:
	cntmax = n - k
print(cntmin, cntmax)


a = list(map(int, input().rstrip().split()))
n = a[0]
k = a[1]
if k == n or k == 0:
	print(0, end=' ')
	print(0)
else:
	print(1, end=' ')
	if 3 * k > n:
		print(n - k)
	else:
		print(2 * k)


(n, k) = map(int, input().split())
if k == 0 or k == n:
	min = 0
	max = 0
else:
	min = 1
	if 3 * k <= n:
		max = 2 * k
	else:
		max = n - k
print(min, max)


def solve(apartment, inhabited):
	freeRooms = apartment - inhabited
	if freeRooms == 0:
		print(0, 0)
	else:
		mini = min(1, inhabited)
		if inhabited * 2 >= freeRooms:
			print(mini, freeRooms)
		else:
			print(mini, inhabited * 2)
(a, i) = list(map(int, input().split()))
solve(a, i)


(n, k) = list(map(int, input().split()))
if k == n or k == 0:
	print('0 0')
elif k < n:
	min = 1
	max = 0
	if n > 3 * k:
		max = 2 * k
	else:
		max = n - k
	print(str(min) + ' ' + str(max))


n = input()
n1 = n.split()
n = int(n1[0])
k = int(n1[1])
str1 = ''
str2 = ''
if k == 0 or k == n:
	str1 = '0 '
else:
	str1 = '1 '
if k == 0:
	str2 = '0'
elif k <= n / 3:
	str2 = str(2 * k)
else:
	str2 = str(n - k)
print(str1 + str2)


(n, k) = input().split()
n = int(n)
k = int(k)
ming = 1 - (n == k)
ming -= k == 0
if n // 3 >= k:
	maxg = 2 * k
else:
	maxg = 2 * (n // 3) - (k - n // 3) + n % 3
print(ming, maxg)


from sys import maxsize, stdout, stdin, stderr
mod = int(1000000000.0 + 7)
import re

def tup():
	return map(int, stdin.readline().split())

def I():
	return int(stdin.readline())

def lint():
	return [int(x) for x in stdin.readline().split()]

def S():
	return input().strip()

def grid(r, c):
	return [lint() for i in range(r)]

def debug(*args, c=6):
	print('\x1b[3{}m'.format(c), *args, '\x1b[0m', file=stderr)
from math import log2, sqrt
(n, k) = tup()
print(min(1, k, n - k), min(n - k, 2 * k))


l = [int(x) for x in input().split()]
if l[1] == 0:
	print(0, 0)
elif l[1] != l[0]:
	print(1, end=' ')
	k = l[0] - l[1]
	j = l[1] * 2
	if k <= j:
		print(k)
	elif j > 0:
		print(j)
	else:
		print(1)
else:
	print(0, 0)


l = input()
l = l.split()
n = int(l[0])
k = int(l[1])
if k == n or k == 0:
	print('0 0')
elif n / k <= 3:
	x = n - k
	print('1', x)
else:
	print(1, k * 2)


(n, k) = list(map(int, input().split()))
min_ok = 1 if 0 < k < n else 0
if k <= n // 3:
	max_ok = k * 2
else:
	max_ok = n - k
print(min_ok, max_ok)


from math import ceil
(n, k) = [int(i) for i in input().split()]
if k == 0 or k == n:
	print(0, 0)
else:
	print(1, end=' ')
	if k >= ceil(n / 3):
		print(n - k)
	else:
		print(2 * k)


def f(l):
	(n, k) = l
	return [min(1, k, n - k), min(k << 1, n - k)]
l = list(map(int, input().split()))
print(*f(l))


(n, k) = list(map(int, input().split()))
g = min(2 * k, n - k)
if k < n and k > 0:
	print('1 ' + str(g))
else:
	print('0 ' + str(g))


(n, k) = [int(i) for i in input().split()]
if k == n:
	print(0, 0)
	exit(0)
if k == 0:
	print(0, 0)
	exit(0)
a = 1
b = 0
h = n // 3
if k <= h:
	b = 2 * k
else:
	k -= h
	b = h * 2 + n % 3
	if n % 3 > 0:
		k -= 1
		b -= 1
	b -= k
print(a, b)


def run():
	line = input().split()
	n = int(line[0])
	k = int(line[1])
	x = 0
	y = 0
	if k == 0 or k >= n:
		x = 0
	else:
		x = 1
		if 3 * k <= n:
			y = 2 * k
		elif 3 * k - 1 <= n:
			y = 2 * k - 1
		elif 3 * k - 2 <= n:
			y = 2 * k - 2
		else:
			y = n - k
	print(x, y)
run()


(N, K) = list(map(int, input().split(' ')))
min_ = 0 if K == 0 or K == N else 1
max_ = min(N - K, K * 2)
print(min_, max_)


(n, k) = [int(x) for x in input().split()]
mn = min(1, n - k)
mx = min(k * 2, n - k)
if k == 0:
	(mn, mx) = (0, 0)
print(mn, mx)


[n, k] = list(map(int, input().split()))
minres = 0 if k == 0 or n == k else 1
t = n // 3
if k <= t:
	res = 2 * k
else:
	res = 2 * t
	k -= t
	if n % 3 == 1:
		k -= 1
	elif n % 3 == 2:
		res += 1
		k -= 1
	res -= k
print('{} {}'.format(minres, res))


(n, k) = (int(x) for x in input().split())
print(min(int(bool(k)), n - k), min(k * 2, n - k))


(n, k) = list(map(int, input().split()))
if k == 0 or k == n:
	print(0, 0)
else:
	mmin = 1
	mmax = 2 * k
	if k > n // 3:
		mmax = n - k
	print(mmin, mmax)


import sys, math

def arrayInput(TYPE):
	return [TYPE(x) for x in input().split()]

def CF():
	(n, k) = arrayInput(int)
	if n == k or k == 0:
		print(0, 0)
		return
	mn = 1
	mx = n - k
	if mx >= 2 * k:
		mx = 2 * k
	print(mn, mx)
CF()


(n, k) = map(int, input().split())
a = 0 if k == 0 or k == n else 1
b = min(2 * k, n - k)
print('%d %d' % (a, b))


def function(n, k):
	result_k = 0
	c = n - k
	if k == 0 or n == k:
		print(*[0, 0])
	if k != 0 and n != k:
		if n - k < 2 * k:
			print(*[1, c])
		if n - k >= 2 * k:
			print(*[1, 2 * k])
(n, k) = map(int, input().rstrip().split())
function(n, k)


(n, k) = map(int, input().split())
minn = 0 if n == k or k == 0 else 1
theor = n // 3
if k <= n // 3:
	maxx = k * 2
else:
	k -= n // 3
	if n % 3 == 2:
		k -= 1
	maxx = n // 3 * 2 + (1 if n % 3 != 0 else 0) - k
print(minn, maxx)


import sys
(n, k) = map(int, input().split())
if k != 0:
	print(str(min(1, n - k)), str(min(2 * k, n - k)))
else:
	print('0 0')


(n, k) = map(int, input().split())
minm = min(1, n - k, k)
if k > n // 2:
	maxm = n - k
else:
	maxm = min(n - k, 2 * k)
print(minm, maxm)


(n, k) = map(int, input().split())
minumum = min(1, k, n - k)
maximum = min(2 * k, n - k)
print(minumum, maximum)


def maximbuys(n, k):
	if k == 0 or k == n:
		return [0, 0]
	if n == 2 and k == 1:
		return [1, 1]
	count = n // 3
	if n % 3 == 0:
		i = n + 2
	if n % 3 == 1:
		i = n + 1
	if n % 3 == 2:
		i = n
	if k <= count:
		return [1, 2 * k]
	maxHouse = 2 * count
	if i == n + 2:
		return [1, maxHouse - (k - count)]
	if i == n + 1:
		if k == count + 1:
			return [1, maxHouse]
		else:
			return [1, maxHouse - (k - count - 1)]
	if i == n:
		if k == count + 1:
			return [1, maxHouse + 1]
		if k == count + 2:
			return [1, maxHouse]
		return [1, maxHouse - (k - count - 2)]
(n, k) = map(int, input().split())
print(*maximbuys(n, k))


S = input()
(n, k) = map(int, S.split())
if n == k or k == 0:
	print('0 0')
else:
	ans = 2 * k
	if ans > n - k:
		ans = n - k
	print(1, ans)


import sys
import math
import itertools
import functools
import collections
import operator
import fileinput
import copy
ORDA = 97

def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return [int(i) for i in input().split()]

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def revn(n):
	return str(n)[::-1]

def dd():
	return collections.defaultdict(int)

def ddl():
	return collections.defaultdict(list)

def sieve(n):
	if n < 2:
		return list()
	prime = [True for _ in range(n + 1)]
	p = 3
	while p * p <= n:
		if prime[p]:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 2
	r = [2]
	for p in range(3, n + 1, 2):
		if prime[p]:
			r.append(p)
	return r

def divs(n, start=2):
	r = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				r.append(i)
			else:
				r.extend([i, n // i])
	return r

def divn(n, primes):
	divs_number = 1
	for i in primes:
		if n == 1:
			return divs_number
		t = 1
		while n % i == 0:
			t += 1
			n //= i
		divs_number *= t

def prime(n):
	if n == 2:
		return True
	if n % 2 == 0 or n <= 1:
		return False
	sqr = int(math.sqrt(n)) + 1
	for d in range(3, sqr, 2):
		if n % d == 0:
			return False
	return True

def convn(number, base):
	newnumber = 0
	while number > 0:
		newnumber += number % base
		number //= base
	return newnumber

def cdiv(n, k):
	return n // k + (n % k != 0)

def ispal(s):
	for i in range(len(s) // 2 + 1):
		if s[i] != s[-i - 1]:
			return False
	return True
(n, k) = mi()
if k == 0 or k == n:
	min_ = 0
else:
	min_ = 1
if k == 0 or k == n:
	max_ = 0
elif k <= n // 3:
	max_ = 2 * k
else:
	max_ = n - k
print(min_, max_)


(n, k) = list(map(int, input().split()))
minimal = 0
if n != k and k != 0:
	minimal = 1
if 2 * k >= n or 3 * k >= n:
	maximal = n - k
else:
	maximal = 2 * k
print(minimal, maximal)


def buying_flat(n, k):
	if k == 0 or k == n:
		return (0, 0)
	if 3 * k >= n:
		return (1, n - k)
	if 3 * k < n:
		if 2 * k < n:
			return (1, 2 * k)
		else:
			return (1, n - k)
(N, K) = [int(i) for i in input().split()]
print(*buying_flat(N, K))


(n, k) = map(int, input().split())
if k == 0 or k == n:
	print('0 0')
else:
	mi = 1
	groups = n // 3
	if groups >= k:
		ma = 2 * k
	else:
		ma = n - k
	print(mi, ma)


(n, k) = [int(i) for i in input().split(' ')]
if k == 0 or k == n:
	s = 0
	b = 0
else:
	s = 1
	if 3 * k <= n:
		b = 2 * k
	else:
		b = n - k
print(s, end=' ')
print(b)


(n, k) = [int(s) for s in input().split()]
if n == k or k == 0:
	print(0, 0)
else:
	print(1, min(n - k, k * 2))


IL = lambda : list(map(int, input().split()))
I = lambda : int(input())
(n, k) = IL()
ans1 = 1 if k % n else 0
if k == 0:
	ans2 = 0
elif k * 3 < n:
	ans2 = k * 2
else:
	ans2 = n - k
print(ans1, ans2)


(n, k) = list(map(int, input().strip().split()))
if k == 0 or k == n:
	print(0, end=' ')
else:
	print(1, end=' ')
print(min(n - k, 2 * k))


(n, k) = map(int, input().split())
ma = 1
mi = 1
if k <= n / 3 and n > 2:
	ma = 2 * k
elif k > n / 3 and k <= n / 3 + n % 3 and (n > 2):
	ma = int(n / 3) * 2 + int(n / 3) + n % 3 - k
else:
	ma = n - k
if k == 0 or k == n:
	ma = mi = 0
print(f'{mi} {ma}')


while True:
	try:
		(n, k) = map(int, input().split())
		n = int(n)
		k = int(k)
		if n == k or k == 0:
			print('0 0')
		else:
			ans = min(2 * k, n - k)
			print('{0} {1}'.format(1, ans))
	except:
		break


import math, sys
(n, k) = [int(x) for x in input().split()]
(mini, maxi) = (0, 0)
h_n = n // 2
if k > h_n:
	maxi = n - k
elif k < h_n:
	res = n // 3
	if res >= k:
		maxi = 2 * k
	else:
		maxi = n - k
elif n % 2 == 1:
	maxi = h_n + 1
else:
	maxi = h_n
if k < n:
	mini = 1
if k == 0:
	(maxi, mini) = (0, 0)
print(mini, ' ', maxi)


(n, k) = list(map(int, input().split()))
if n == 1:
	print(0, 0)
elif k == 0 or k == n:
	print(0, 0)
else:
	print(1, min(2 * k, n - k))


(n, k) = input().strip().split(' ')
(n, k) = [int(n), int(k)]
if k == n:
	ans1 = 0
elif k == 0:
	ans1 = 0
else:
	ans1 = 1
if k * 3 >= n:
	ans2 = n - k
else:
	ans2 = 2 * k
print(ans1, ans2)


(n, k) = map(int, input().split())
mini = min(1, k, n - k)
maxi = min(n - k, 2 * k)
print(mini, maxi)


import math
import collections
import bisect
import heapq
import time
import random
import itertools
(N, K) = map(int, input().split())
if K == N or K == 0:
	print(0, 0)
else:
	print(1, min(N - K, K * 2))


import sys
(n, k) = map(int, sys.stdin.readline().split())
if k == 0 or k == n:
	print(0, 0)
else:
	print(1, min(n - k, k * 2))


(n, k) = input().strip().split()
(n, k) = [int(n), int(k)]
tmp = []
if n == k or k == 0:
	tmp = [0, 0]
else:
	tmp = [1, min(n - k, 2 * k)]
print(' '.join(map(str, tmp)))


(n, k) = map(int, input().split())
x = n // 3
if k == 0 or k == n:
	print(0, end=' ')
	print(0)
elif x >= k:
	print(1, end=' ')
	print(k * 2)
elif k > x:
	print(1, end=' ')
	print(n - k)


def run():
	(n, k) = [int(x) for x in input().split()]
	if n == k or k == 0:
		print(0, 0)
		return
	if n - k <= 2 * k:
		print(1, n - k)
	else:
		print(1, 2 * k)
	return
run()


import math
import re

def ria():
	return [int(i) for i in input().split()]
(n, k) = ria()
if n == 2 and k == 1:
	print(1, 1)
	exit(0)
al = min(n // 3, k)
oppo = al * 2
left = n - al - oppo
k -= al
if left == 2 and k == 1:
	left = 0
	k -= 1
	oppo += 1
k -= min(k, left)
minop = min(k, oppo)
k -= minop
oppo -= minop
print(min(1, oppo), oppo)


(n, k) = (int(e) for e in input().split())
if k == 0 or n == k:
	print(0, 0)
elif n >= k * 3:
	print(1, k * 2)
else:
	print(1, n - k)


(n, k) = map(int, input().split())
if n - k >= 1 and k > 0:
	min_ = 1
else:
	min_ = 0
if n // 3 <= n - k:
	max_ = min(2 * k, n - k)
else:
	max_ = n - k
print(min_, max_)


(n, k) = map(int, input().split())
mi = 1
if k == 0:
	print(0, 0)
	exit()
if k == n:
	print(0, 0)
	exit()
if 3 * k <= n:
	ma = 2 * k
else:
	ma = n - k
print(mi, ma)


(n, k) = input().split(' ')
(n, k) = (int(n), int(k))
if n == k:
	print('0 0')
elif k == 0:
	print('0 0')
else:
	x = int(n / 3)
	if k <= x:
		print('1 ' + str(2 * k))
	else:
		print('1 ' + str(n - k))


import math
(n, k) = map(int, input().split())
if k == 0:
	print(0, 0)
elif n == k:
	print(0, 0)
elif n == k:
	print(0, 0)
elif n - 1 == k:
	print(1, 1)
else:
	x = n // 3
	if k <= x:
		print(1, 2 * k)
	else:
		print(1, n - k)


(N, K) = map(int, input().split())
if K == 0 or K == N:
	print(0, 0, sep=' ')
elif 1 <= K <= N // 3:
	print(1, 2 * K, sep=' ')
else:
	res = 2 * (N // 3)
	K -= N // 3
	if N % 3 == 1:
		K -= 1
	elif N % 3 == 2:
		K -= 1
		res += 1
	res -= K
	print(1, res, sep=' ')


(n, k) = map(int, input().split())
if k >= n // 3 + 1:
	x = n - k
else:
	x = 2 * k
y = 1
if k == 0 or k == n:
	y = 0
print(y, x)


(n, k) = map(int, input().split())
mi = 1
mx = n
if k == n or k == 0:
	mi = 0
	mx = 0
elif k <= n // 3:
	mx = k * 2
else:
	mx = n - k
print(mi, mx)


def apartment(n, k):
	maxi = 0
	mini = 1
	if n == k or k == 0:
		mini = 0
	elif n >= 3 * k:
		maxi = 2 * k
	elif 3 * k > n > 2 * k:
		maxi = n - k
	elif n == 2 * k:
		maxi = k
	elif k < n < 2 * k:
		maxi = n - k
	print(mini, maxi)
(n, k) = input().split()
ans = apartment(int(n), int(k))


(n, k) = (int(x) for x in input().split())
if k == n:
	print(0, 0)
elif 3 * k <= n:
	print(min(1, k), 2 * k)
else:
	print(min(1, k), n - k)


(n, k) = map(int, input().split())
if n == k or k == 0:
	print(0, 0)
	exit()
print(1, min(n - k, k * 2))


import sys

def main():
	(n, k) = map(int, sys.stdin.readline().split())
	if k == 0 or k == n:
		print(0, 0)
		return
	if k * 3 >= n:
		m = n - k
	else:
		m = 2 * k
	print(1, m)
main()


(n, k) = map(int, input().split())
s = 0
if k == n:
	minkv = 0
	maxkv = 0
elif k == 0:
	minkv = 0
	maxkv = 0
else:
	minkv = 1
	s = n - k
	if n % 3 != 0:
		t = n // 3 + 1
	else:
		t = n // 3
	if k == t:
		maxkv = n - t
	elif k < t:
		maxkv = k * 2
	else:
		maxkv = n - t - (k - t)
print(minkv, maxkv)


from sys import stdout
from random import randint
from math import *
import re
(n, k) = map(int, input().split())

def find_min(n, k):
	return 0 if k == 0 or k == n else 1

def find_max(n, k):
	return min(k * 2, n - k)
print(find_min(n, k), find_max(n, k))


(n, k) = (int(i) for i in input().split())
print(int(n - k > 0 and k != 0), min(k * 2, n - k))


a = [int(x) for x in input().split()]
(n, k) = (a[0], a[1])
if 3 * k <= n:
	m = 2 * k
else:
	m = n - k
if n == k:
	print(0, 0)
elif k == 0:
	print(0, 0)
else:
	print(1, m)


(n, k) = map(int, input().strip().split())
answ = 0
flag = False
if k == 0 or n == k:
	print(0, 0)
elif n // 3 >= k:
	print(1, k * 2)
else:
	print(1, n - k)


(n, k) = input().split(' ')
(n, k) = (int(n), int(k))
if 0 <= k <= n <= 1000000000 and 1 <= n:
	if n == k or k == 0:
		(x, y) = (0, 0)
	else:
		x = 1
		if n - k <= k * 2:
			y = n - k
		else:
			y = k * 2
	print(x, y)


(n, k) = map(int, input().split())
if k == n or k == 0:
	print(0, 0)
else:
	s = k * 2
	if s > n - k:
		print(1, n - k)
	else:
		print(1, s)


(n, m) = map(int, input().split())
mxx = min(n - m, m * 2)
mnn = int(1)
if n == m or m == 0:
	mnn = int(0)
print(mnn, mxx)


(n, k) = map(int, input().split())
if n == k or k == 0:
	print('0 0')
elif k * 2 + k <= n:
	print('1 ' + str(k * 2))
else:
	print('1 ' + str(n - k))


(n, k) = map(int, input().split())
if k == 0 or k == n:
	print(0, 0)
else:
	a = 1
	x = n // 3
	if k <= x:
		b = 2 * k
	else:
		b = n - k
	print(a, b)


(n, k) = input().split()
mn = 0
(n, k) = (int(n), int(k))
if k > 0 and k < n:
	mn = 1
mx = min(k * 2, n - k)
print(mn, mx)


from sys import stdin as fin
(n, k) = map(int, fin.readline().split())
print(1 * (n > k and k > 0), min(k * 2, n - k))


(n, k) = map(int, input().split())
(m, M) = (0, 0)
if n > k > 0:
	m = 1
K = (n + 2) // 3
if k < K:
	M = k * 2
else:
	M = n - k
print(m, M)


(n, k) = map(int, input().split())
minimum = min(min(1, n - k), k)
maximum = min(2 * k, n - k)
print(minimum, maximum)


a = input().split()
n = int(a[0])
k = int(a[1])

def f(n, k):
	ans1 = 0
	ans2 = 0
	if k == 0:
		print(ans1, ans2)
		return
	if k < n:
		ans1 = 1
		if k <= n / 3:
			ans2 = k * 2
		elif k > n / 3:
			ans2 = n - k
		else:
			pass
		print(ans1, ans2)
	if k == n:
		print(ans1, ans2)
		return
f(n, k)


(n, k) = map(int, input().split())
q = 0
m = 0
if k != 0:
	q = n // k
	m = n % k
if (q == 1) & (m == 0):
	print('0 0')
elif (q == 1) & (m > 0):
	print('1 ' + str(m))
elif (q == 2) & (m == 0):
	print('1 ' + str(k))
elif (q == 2) & (m > 0):
	print('1 ' + str(k + m))
elif q >= 3:
	print('1 ' + str(k * 2))
else:
	print('0 0')


def main():
	line = input()
	line = line.split(' ')
	n = int(line[0])
	k = int(line[1])
	minimum = 1
	if k == 0 or k == n:
		minimum = 0
	maximum = n // 3
	if k <= maximum:
		maximum = 2 * k
	else:
		maximum = 2 * (n // 3)
		k = k - n // 3
		if n % 3 == 1:
			k -= 1
		if n % 3 == 2:
			k -= 1
			maximum += 1
		maximum -= k
		if maximum <= 0:
			maximum = 0
	print(str(minimum) + ' ' + str(int(maximum)))
main()


import math
(n, k) = map(int, input().split())
if k == 0 or n == k:
	print(0, 0)
elif k >= math.ceil(n / 3):
	print(1, n - k)
else:
	print(1, 2 * k)


read = lambda : map(int, input().split())
(n, k) = read()
mn = 0 if k == 0 or k == n else 1
mx = min(n - k, 2 * k)
print(mn, mx)


(n, a) = map(int, input().split())
if n == a or a == 0:
	print(0, 0)
	exit()
mx = min(n - a, a * 2)
print(1, mx)


(n, m) = map(int, input().split())
if m == 0 or m == n:
	print(0, 0)
else:
	x = n // 3
	if m <= x:
		print(1, 2 * m)
	else:
		print(1, n - m)


(n, k) = map(int, input().split())
if k == 0:
	mini = 0
	maxi = 0
elif k == n:
	mini = 0
	maxi = 0
else:
	mini = 1
	maxi = 2 * k
	maxi = min(maxi, n - k)
print(mini, maxi)


(n, k) = [int(f) for f in input().split()]
a = 0 if n == k or k == 0 else 1
b = k * 2 if n // 3 >= k else n - k
print(a, b if k != 0 else 0)


(n, k) = map(int, input().split())

def min(a, b):
	if a < b:
		return a
	return b
if k == 0:
	print(0, 0)
else:
	print(min(n - k, 1), min(n - k, 2 * k))


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
gosa = 1.0 / 10 ** 10
mod = 10 ** 9 + 7

def LI():
	return [int(x) for x in sys.stdin.readline().split()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def main():
	(n, k) = LI()
	if k == 0 or n == k:
		return '0 0'
	return '1 {}'.format(min(n - k, k * 2))
print(main())


from sys import exit
(n, k) = map(int, input().split())
if k == 0:
	print(0, 0)
else:
	print(min(1, n - k), min(2 * k, n - k))