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: interview

Starter code:

Solutions:
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())





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)


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

print(min(n - k, min(k, 1)), min(2 * k, n - k))

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())
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)

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)


from sys import stdin, stdout

n,k = list(map(int,stdin.readline().rstrip().split()))

minH = min([1,k,n-k])
maxH = min([2*k,n-k])

print(str(minH) + ' ' + str(maxH))


#!/bin/python3

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=list(map(int,input().split()))
low=-1
high=-1
if k==0:
    low=0
    high=0
else:
    if k==n:
        low=0
        high=0
    else:
        low=1
        if n>=3*k:
            high = 2*k
        else:
            high = n-k
print(low,high)


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)

import sys


def main():
    n, k = list(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()


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)




n, k = list(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))


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

from sys import stdout
from random import randint 
from math import *
import re


n, k = list(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 = 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)

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())
worst = 1 if 1 <= k < n else 0
best = min(n-k, 2*k)
print(worst, best)

n, k = list(map(int, input().split()))
if n == 1 or k == 0 or k == n:
    print(0, 0)
elif n // k < 3:
    print(1, n-k)
else:
    print(1, 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())

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))

n, m = list(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)


n,k=[int(i)for i in input().split()]
if k==n:
	print(0,0)
	return
if k==0:
	print(0,0)
	return		
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)	  	





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 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)