t=int(input())
for _ in range(t):
    x=int(input())
    ans=0
    if x%2:
        ans+=1
        x-=3
        ans+=x//2

    else:
        ans=x//2

    print(ans)

for _ in range(int(input())):
    n=int(input())
    if(n%6==0):
        print(n//6)
    else:
        print(n//6 +1)

from sys import stdin
from sys import stdout

sprint = stdout.write
sinput = stdin.readline

def func():
    n = int(input())
    c = 0
    if n%2 == 1:
        c = 1
        n -= 3
    c += n//2

    print(c)

if __name__ == "__main__":
    t = int(sinput())
    while t != 0:
        t -= 1
        func()

for i in range(int (input())):
    n =  int (input())
    print (n//2)

for _ in range(int(input())):
    x = int(input())
    if x == 3:
        print(1)
    else:
        print(x // 2)

import sys
import math
import bisect

def main():
    for _ in range(int(input())):
        n = int(input())
        ans = 0
        while n:
            if n == 3:
                n -= 3
                ans += 1
            else:
                n -= 2
                ans += 1
        print(ans)

if __name__ == "__main__":
    main()

def main():
    for _ in range(int(input())):
        n = int(input()) + 1
        l = [99] * n
        l[0] = 0
        for step in range(7, 1, -1):
            for i, b in enumerate(l[:]):
                for c, j in enumerate(range(i, n, step), b):
                    l[j] = min(l[j], c)
                if l[-1] < 99:
                    break
        print(l[-1])

if __name__ == '__main__':
    main()

n = int(input())
for i in range(n):
    a = int(input())
    print(a//2)

t = int(input())
for i in range(t):
    a = int(input())
    print(a // 2)

def answer():
    n = int(input())
    while n:
        a=int(input())
        print(int(a/2))
        n-=1
answer()

t=int(input())
for _ in range(t):
    n=int(input())
    print(n//7+1)

for i in range(int(input())):
	print(int(input())//2)

t=int(input())
for i in range(t):
    print(int(input())//2)

import math
for _ in range(int(input())):
	print(math.ceil(int(input())/7))

import math
list=[6,5,4,3,2]
n=int(input())
for i in range(n):
	count=0
	y=int(input())
	for j in list :
		while y>=j :
			if y%j==0:
				t=math.floor(y/j)
				count=count+t
				y=y%j
				break
			elif y%j>0 and y>j and y-j >=2:
				y=y-j
				count=count+1
			else:
				break

	print(count)

a=int(input())
for i in range(a):
  b=int(input())
  print(b//2)

for _ in range(int(input())):
    x = int(input())
    print(x//2)

n = int(input())
angka = [2,3,4,5,6,7]

for i in range(n):
    hasil = 0
    dice = int(input())
    for j in angka:
        if dice >= j:
            hasil += dice // j
            dice = dice % j
        if dice == 0:
            break
    print(hasil)

import bisect
from collections import defaultdict
from collections import deque
import math
import re
import sys
import itertools

def ni():
    return int(raw_input())

def nis():
    return map(int, raw_input().split())

def si():
    return raw_input()

def sis():
    return raw_input().split()

def spaced(a):
    return ' '.join(map(str, a))

t = ni()
for _ in range(t):
    x = ni()
    d, m = divmod(x, 7)
    print d if not m else d + 1

t=int(input())
while(t>0):
    n=int(input())
    if(n%7==0):
        print(int(n/7))
    else:
        print(int(n/7)+1)
    t-=1

for i in range(int(input())):
    a = int(input())
    e = a // 2
    if a % 2 == 0:
        print(e)
    else:
        o = e * 2 - 2 + 3
        print(e)

t=int(input())
for i in range(t):
    n=int(input())
    print(n//2 if n%2==0 else (n-3)//2+1)

def solve():
    num = int(input())
    rolls = 0
    if 2 <= num < 7:
        print('1')
    else:
        if ( num%7 == 1 ):
            print((int(num/7)-1) + 2 )
        elif ( num%7 == 0 ):
            print( int(num/7) )
        else:
            print(int(num/7) + 1)

num = int(input())
for x in range(num):
    solve()

for i in range(int(input())):print(int(input())//2)

t=int(input())

for i in range(t):
    n=int(input())
    sum=0;
    i=7;
    while n:
        k=n//i
        if k:
            n=n-k*i
            sum+=k
        i-=1
    print(sum)

for _ in range(int(input())):
    n=int(input())
    if n%7==0:
        print(n//7)
    else:
        print(n//7+1)

t=int(input())
for i in range(t):
    n=int(input())
    print(n//2)

n = int(input())
for i in range(n):
     print(int(int(input())/2))

n = int(input())

for i in range(n):
     count = 0
     a = int(input())
     count += int(a/2)
     print(count)

import os
import heapq
import sys,threading
import math
import bisect
import operator
from collections import defaultdict
sys.setrecursionlimit(10**5)
from io import BytesIO, IOBase
def gcd(a,b):
    if b==0:

        return a
    else:
        return gcd(b,a%b)
def power(x, p,m):
    res = 1
    while p:
        if p & 1:
            res = (res * x) % m
        x = (x * x) % m
        p >>= 1
    return res
def inar():
    return [int(k) for k in input().split()]

def lcm(num1,num2):
    return (num1*num2)//gcd(num1,num2)
# Python3 function to
# calculate nCr % p
def ncr(n, r, p):
	# initialize numerator
	# and denominator
	num = den = 1
	for i in range(r):
		num = (num * (n - i)) % p
		den = (den * (i + 1)) % p
	return (num * pow(den,
			p - 2, p)) % p

# p must be a prime
# greater than n
# n, r, p = 10, 2, 13
# print("Value of nCr % p is",
# 			ncr(n, r, p))
def check(n,m,arr):
    c1,c2=1,1
    for i in range(n):
        for j in range(1,m):
            if arr[i][j]>arr[i][j-1]:
                continue
            else:
                c1=0
                break
    for i in range(m):
        for j in range(1,n):
            if arr[j][i]>arr[j-1][i]:
                continue
            else:
                c2=0
                break
    if c1 and c2:
        return True
    else:
        return False

def main():
    for _ in range(int(input())):
        n=int(input())
        print(n//2)

    # n,m=inar()
    # arr1=[]
    # arr2=[]
    # for i in range(n):
    #     take=inar()
    #     arr1.append(take)
    # for i in range(n):
    #     take=inar()
    #     arr2.append(take)
    # # print(arr1)
    # for i in range(n):
    #     for j in range(m):
    #         mn=min(arr1[i][j],arr2[i][j])
    #         mx=max(arr1[i][j],arr2[i][j])
    #         arr1[i][j],arr2[i][j]=mn,mx
    # if check(n,m,arr1) and check(n,m,arr2):
    #     print("Possible")
    # else:
    #     print("Impossible")

BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)

class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")

sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

if __name__ == "__main__":
    main()
    #threadin.Thread(target=main).start()

n=int(input())
for i in range(n):
	n1=int(input())
	count=0
	for i in range(7,1,-1):
		if n1!=1:
			count+=int(n1//i)
			n1%=i
		elif n1==1:
			count+=1
			break
		# print(n1)
	print(count)

for _ in range(input()):
  n=input()
  print n/7+(n%7>0)

n = int(raw_input())
#ver,reb = [int(x) for x in raw_input().split(' ')]

for i in range(n):
    x = int(raw_input())
    num = x // 7
    if x % 7:
        num += 1
    print(num)

n=input()
for t in range(n):
	r=input()

	if r in range(2,8):
		ans= 1
	elif r%7==0:
		ans= r/7
	else:
		ans= (r/7)+1
	print ans

t = int(input())
for i in range(t):
    num = int(input())
    x = num / 7
    if (num % 7):
        x += 1
    print x

# import atexit, io, sys
# buffer = io.BytesIO()
# sys.stdout = buffer
# @atexit.register
# def write():
#     sys.__stdout__.write(buffer.getvalue())

# def main():
# main()

n = int(input())
L = []
for i in range(n):
    x = int(input())
    s = x//7
    x -= (7*s)
    if x:
        s += 1
    L.append(s)
for i in L:
    print(i)

# Author : raj1307 - Raj Singh
# Date   : 17.05.2020

from __future__ import division, print_function

import os,sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip

def ii(): return int(input())
def si(): return input()
def mi(): return map(int,input().strip().split(" "))
def msi(): return map(str,input().strip().split(" "))
def li(): return list(mi())

def dmain():
    sys.setrecursionlimit(100000000)
    threading.stack_size(40960000)
    thread = threading.Thread(target=main)
    thread.start()

#from collections import deque, Counter, OrderedDict,defaultdict
#from heapq import nsmallest, nlargest, heapify,heappop ,heappush, heapreplace
#from math import log,sqrt,factorial,cos,tan,sin,radians
#from bisect import bisect,bisect_left,bisect_right,insort,insort_left,insort_right
#from decimal import *,threading
#from itertools import permutations
#Copy 2D list  m = [x[:] for x in mark] .. Avoid Using Deepcopy

abc='abcdefghijklmnopqrstuvwxyz'
abd={'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
mod=1000000007
#mod=998244353
inf = float("inf")
vow=['a','e','i','o','u']
dx,dy=[-1,1,0,0],[0,0,1,-1]
def getKey(item): return item[1]
def sort2(l):return sorted(l, key=getKey,reverse=True)
def d2(n,m,num):return [[num for x in range(m)] for y in range(n)]
def isPowerOfTwo (x): return (x and (not(x & (x - 1))) )
def decimalToBinary(n): return bin(n).replace("0b","")
def ntl(n):return [int(i) for i in str(n)]
def ncr(n,r): return factorial(n)//(factorial(r)*factorial(max(n-r,1)))

def ceil(x,y):
    if x%y==0:
        return x//y
    else:
        return x//y+1

def powerMod(x,y,p):
    res = 1
    x %= p
    while y > 0:
        if y&1:
            res = (res*x)%p
        y = y>>1
        x = (x*x)%p
    return res

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

def isPrime(n) : # Check Prime Number or not
    if (n <= 1) : return False
    if (n <= 3) : return True
    if (n % 2 == 0 or n % 3 == 0) : return False
    i = 5
    while(i * i <= n) :
        if (n % i == 0 or n % (i + 2) == 0) :
            return False
        i = i + 6
    return True

def read():
    sys.stdin = open('input.txt', 'r')
    sys.stdout = open('output.txt', 'w')

def main():

    for _ in range(ii()):

        n=ii()
        if n<=7:
            print(1)
        else:
            print(ceil(n,7))

# region fastio
# template taken from https://github.com/cheran-senthil/PyRival/blob/master/templates/template.py

BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)

class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")

def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()

if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)

input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    #read()
    main()
    #dmain()

# Comment Read()

'''input
4
2
13
37
100

'''

for _ in range(input()):
    n=input()
    print n/2

import sys
range = xrange
input = raw_input

t = int(input())
for _ in range(t):
    x = int(input())
    ans = 0
    if x%2==1:
        ans += 1
        x -= 3
    ans += x//2
    print ans

n = int(raw_input())
for _ in xrange(n):
    x = int(raw_input())
    for i in xrange(7, 1, -1):
        v = x / i
        d = x % i
        if d == 0:
            print v
            break
        elif d == 1:
            continue
        else:
            print v + 1
            break

n=int(input())
for x in range(n):
	s=0
	a=int(input())
	for x in range(2,8):
		if a%(9-x)==0:
			s+=(a//(9-x))
			break
		elif a%(9-x)!=1:
			s+=(a//(9-x))
			a=a%(9-x)
	print(s)

# your code goes here
for i in range(int(input())):
	x=int(input())
	print(int(x/7)+1)

# Dice Rolling
def dice(x):
    if x <= 7:
        return 1
    if x % 2 == 0:
        return x // 2
    ans = 0
    while True:
        if x % 2 == 0:
            return (ans + (x // 2))
        elif x >= 7:
            x -= 7
            ans += 1
        elif x >= 5:
            x -= 5
            ans += 1
        elif x >= 3:
            x -= 3
            ans += 1

t = int(input())
for i in range(t):
    x = int(input())
    print(dice(x))

n = int(raw_input())
for i in range(n):
    m = int(input())
    if m%2 == 0:print(m/2)
    elif m == 1:print(0)
    else: print(1+((m-3)/2))

t=int(input())
while t>0:
    t-=1
    n=int(input())
    print(n//2)

for i in range(int(input())):
	print(int(input())//2)

#!/usr/bin/python2

from heapq import *

def ir(): return int(raw_input())
def ia(): return map(int, raw_input().split())

n = ir()
for i in xrange(n):
    x = ir()

    ans = 0
    while x > 3:
        x -= 2
        ans += 1
    if x == 2:
        ans += 1
    else:
        ans += 1
    print ans

T=int(input())
for i in range(T):
    x=int(input())
    if(x%2==0):
        print(x//2)
    else:
        print((x-3)//2+1)

import math
import sys
import bisect
input=sys.stdin.readline
t=int(input())
#t=1
for _ in range(t):
    n=int(input())
    print(n//7+1)

for _ in range(int(input())):
    print(int(input())//2)

t=int(raw_input())
for i in range(t):
    x=int(raw_input())
    cnt=x/7
    if x<8:
        x=1
    else:
        x=cnt+1
    print x

for i in[0]*int(input()):
    print(int(input())//2)

z=input
for _ in range(int(z())):
    x=int(z())
    print(x//2)

x = int(input())
for i in range(x):
	a = int(input())
	k = 0
	if a > 7:
		t = int(a/7)
		a = a - 7*t
		k = k + t
	if a > 0:
		a = 0
		k = k + 1
	print(k)

# https://vjudge.net/contest/319028#problem/F

n = int(input())

for i in range(n):
    t = int(input())
    result = 0
    for i in range(7, 1, -1):
        while t >= i:
            t -= i
            result += 1
    if t == 1:
        result += 1
    print(result)

T = int(input())
while(T > 0):
    T -= 1
    n = int(input())
    print((n + 6) // 7)

def dice(q):
    div = q / 2
    return div

n = int(raw_input())
queries = []
for i in range(n):
    q = int(raw_input())
    queries.append(q)

for q in queries:
    print(dice(q))

import sys
import math
#import random
sys.setrecursionlimit(100000)
input = sys.stdin.readline

############ ---- USER DEFINED INPUT FUNCTIONS ---- ############
def inp():
    return(int(input()))
def inara():
    return(list(map(int,input().split())))
def insr():
    s = input()
    return(list(s[:len(s) - 1]))
def invr():
    return(map(int,input().split()))
################################################################
############ ---- THE ACTUAL CODE STARTS BELOW ---- ############

t=inp()

for _ in range(t):
	n=inp()

	if n<=7:
		print(1)
	else:
		if n%2:
			ans=(n-3)//2+1
			print(ans)
		else:
			print(n//2)

c= int(input())
for k in range(c):
    d = int(input())
    if d % 2 == 0:
        print(d // 2)
    else:
        print(((d - 3) // 2)+ 1)

for _ in xrange(input()):print input()/2

for i in xrange(input()):
    print input()/2

n = int(input())
for i in range(n):
    tmp = int(input())
    ans = tmp // 7 + (1 if tmp % 7 != 0 else 0)
    print(ans)

for i in range(int(input())):
    print((int(input()) + 6) // 7)

#!/usr/bin/env python
# -*- coding: utf-8 -*-
# File              : a.py
# Author            : recurze
# Date              : 20:06 15.12.2018
# Last Modified Date: 20:07 15.12.2018

for _ in xrange(int(raw_input())):
    print int(raw_input())/2

import sys
input = sys.stdin.readline
ins = lambda: input().rstrip()
ini = lambda: int(input().rstrip())
inm = lambda: map(int, input().rstrip().split())
inl = lambda: list(map(int, input().split()))
out = lambda x, s='\n': print(s.join(map(str, x)))

t = ini()
for _ in range(t):
    n = ini()
    print((n + 6) // 7)

t = int(raw_input())
while t > 0:
	n = int(raw_input())
	x = n/7
	if n%7 != 0:
		x = x+1
	print x
	t -= 1

n = int(input())
for i in range(n):
    x = int(input())
    print(int(x/2))

a=[2,3,4,5,6,7]
x=input()
t=0
R=[]
while t<int(x):
    y=int(input())
    rounds=0
    if y>7:
        if y%7!=0:
            rounds=y//7 +1
        else:
            rounds=y//7
    else:
         rounds=1
    R.append(rounds)
    t+=1
for r in R:
    print(r)

for _ in range(input()):
	print input()/2

test_case = int(input())

for _ in range(test_case):
    x = int(input())

    print((x + 7 - 1)//7)

for i in range(int(input())):
    print(int(input())//2)

n = int(input())

for i in range(n):
    a = int(input())
    print(a // 2)

for _ in range(int(input())):
    x = int(input())
    if(x<=7 and x>=2):
        print(1)
    else:
        if(x%2==0):
            print(x//2)
        else:
            x-=3
            print(x//2+1)

n=int(input())
for i in range(n):
    x=int(input())
    if(x<=7):
        print(1)
    else:
        d=x//7
        if(x%7==0):
            print(d)
        else:
            print(d+1)

x=int(input())
for i in range(0,x):
    n=int(input())
    if(n%7==0):
        print(n//7)
    else:
        print((n//7)+1)

t = int(input())
nums = [int(input()) for i in range(t)]
for k in nums:
	if k%2==0:
	    print(int(k/2))
	elif k==3:
	    print("1")
	else:
	    print(int((k-3)/2))

# cf 1093 A (700)
t = int(input())
for _ in range(t):
    n = int(input())
    c = 0
    while n > 0:
        if n > 7:
            n -= 7
            c += 1
        elif n == 1:
            c += 2
            n -= 1
        else:
            c += 1
            n -= n
    print(c)

t=int(input())
for _ in range(t):
    n=int(input())
    a=[7,6,5,4,3,2]
    x=0
    i=0
    while(i<6 and n>0 ):
        if n<a[i]:
            i+=1
        else:
            c=n%a[i]
            x+=n//a[i]
            n=c
    if n==1:
        x+=1
    print(x)

from math import ceil
t=int(input())
a=[]
for i in range(t):
    a.append(int(input()))
def chk(k):
    return ceil(k/7)
for i in a:
    print(chk(i))

t = int(input())
for q in range(t):
            a = int(input())
            if a==2:
                        num = 1
            elif a==3:
                        num = 1
            elif a==4:
                        num = 1
            elif a>4:
                        if a%5==0:
                                    num = (a//5)
                        elif a%5!=0:
                                    num = (a//5)+1
            print(num)

import math

case = int(input())
for caseNum in range(0, case):
    n = int(input())
    print(math.ceil(n / 7))

def solver():
    number = int(input())
    combinations = [2,3,4,5,6,7]
    for i in combinations:
        if number%i == 0:
            return (int(number/i))

    count = 1
    new_number = number - 3
    count = count + (new_number//2)
    return count

n = int(input())

for i in range(n):
    print(solver())

for _ in range(int(input())):
    n = int(input())
    if n%2 == 0:
        print(n//2)
    else:
        print((n-3)//2 + 1)

n = int(input())
for i in range(n):
    x = int(input())
    print(x // 2)

a=int(input())
b=0
for i in range(a):
    b=int(input())
    print((b+6)//7)

for i in range(int(input())):
    n = int(input())
    if n & 1:
        print((n - 3) // 2 + 1)
    else:
        print(n // 2)

for i in range(int(input())):
    n = int(input())
    if(n == 2 or n == 3 or n == 4 or n == 5 or n == 6 or n == 7):
        print(1)
    else:
        print(round(n / 7) + 1)

t=int(input())
while t>0:
    t-=1
    n=int(input())
    ans = 0
    if n>7:
        a = n // 7
        n = n - a*7
        ans += a
    if n>6:
        a = n // 6
        n = n - a*6
        ans += a
    if n>5:
        a = n // 5
        n = n - a*5
        ans += a
    if n>4:
        a = n // 4
        n = n - a*4
        ans += a
    if n>3:
        a = n // 3
        n = n - a*3
        ans += a
    if n>2:
        a = n // 2
        n = n - a*2
        ans += a
    print(ans)

x = int(input())
for i in range(x):
	a = int(input())
	k = 0
	if a > 7:
		t = int(a/7)
		a = a - a*t
		k = k + t
	if a > 0:
		a = 0
		k = k + 1
	print(k)

import sys
import math

#to read string
get_string = lambda: sys.stdin.readline().strip()
#to read list of integers
get_list = lambda: list( map(int,sys.stdin.readline().strip().split()) )
#to read non spaced string and elements are integers to list of int
get_intList_from_str = lambda: list(map(int,list(sys.stdin.readline().strip())))
#to read non spaced string and elements are character to list of character
get_strList_from_str = lambda: list(sys.stdin.readline().strip())
#to read integers
get_int = lambda: int(sys.stdin.readline().strip())
#to print faster
pt = lambda x: sys.stdout.write(str(x))

#--------------------------------WhiteHat010--------------------------------------#
for _ in range(get_int()):
    rolls = 0
    n = get_int()
    temp = n
    start = 7
    while True:
        temp = n
        for i in range(start,1,-1):
            rolls += temp//i
            temp = temp%i
        if temp == 0:
            break
        else:
            start -= 1

    print(rolls)

#1093A in codeforces
t = int(input())
dice = [2,3,4,5,6,7]
for _ in range(t):
	rolls = 0
	n = int(input())
	for i in range(5,-1,-1):
		rolls+= n//dice[i]
		n = n%dice[i]
	print(rolls)

points = [7, 6, 5, 4, 3, 2]

def is_divisible(number):
    for i in points:
        if number % i == 0:
            return True

    return False

def get_number_of_rolls(score):
    if score == 0:
        return 0

    rolls = 0
    actual_score = 0

    for i in points:
        if score % i == 0:
            return score // i

    for i in points:
        mod = score % i
        print(mod)

        if is_divisible(mod):
            return (score // i) + get_number_of_rolls(mod)

n = int(input())

for i in range(n):
    score = int(input())

    print(get_number_of_rolls(score))

import sys

t=int(raw_input())
for _ in xrange(t):
	n=int(raw_input())
	print(n/2+(0 if n%2==0 else 1))

n = int(input())
for item in range(n):
    a = int(input())
    if a <= 7:
        print(a)
    else:
        if a % 2 == 0:
            print(a //2)
        else:
            print((a//2) + 1)

import random;
t = input();
t = int(t);
x = [];
for j in range(t):
    a = input();
    a = int(a);
    x.append(a);
g = max(x);
m = g//7+1;
y =0;

for i in range(len(x)):
    if x[i]==1 or x[i]==0:
        print(0);
    if x[i]==2 or x[i]== 3 :
        b = 1;
        print(b);
    else:
        if x[i]//7 == x[i]/7:
            lower = x[i]//7;
            print(lower);
        else:
            lower = x[i]//7 + 1;
            print(lower);

        upper = x[i]//2;
        print(upper);

        b = random.randint(lower,upper);
        print(b);

import random
def roll_dice():
	t=int(input("Enter the no. of queries"))
	sum=0
	count=0
	for i in range(t):
		x=int(input("Enter the sum of number"))
		sum=sum+random.randint(2,7)
		#print("first sum",sum)
		count=count+1
		#print("first count",count)

		while(sum!=x):
			if sum<x:
				sum=sum+random.randint(2,7)
				#print("heyyy",sum)
				count=count+1
				continue

			elif sum>x:

				sum=0
				count=0
				#print("greater than entered")

			else:
				count=count+1
				break

		#print("final", sum)
		print("final count", count)
		sum=0
		count=0
roll_dice()

for i in range(int(input())):
    a = int(input())
    if a % 2 == 0:
        print(a//2)
    elif a % 2 != 0:
        e = a // 2
        w = abs(e-3)
        if w == 0:
            print(1)
        else:
            print(w)

T = int(input())

for i in range(0, T):
    x = int(input())
    roll = x//7 + x%7
    print(roll)

int_=int(input())
for i in range(int_):
    k=int(input())
    num=(k+1)//2
    print(num)

x = int(input())
y = [int(input()) for c in range(x)]

for c in range(x):
    print((y[c])//7)

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sat Dec 15 20:59:44 2018

@author: mach
"""

t = int(input())
l = [7,6,5,4,3,2]
for _ in range(t):
    s = 0
    u = int(input())

    for i in l:
        if u  >= 2:
            s += u//i
            u = u%i
    print(s)

n = int(input())
for i in range(n):
    x = int(input())
    print(x % 7 + 1)

import math
list=[6,5,4,3,2]
n=int(input())
for i in range(n):
	count=0
	y=int(input())
	for j in list :
		while y>=j :
			if y%j==0:
				t=math.floor(y/j)
				count=count+t
				y=y%j
				break
			elif y%j>0 and y>j and y%j in list:
				y=y-j
				count=count+1
			else:
				break

	print(count)

n = int(input())
for i in range(n):
    tmp = int(input())
    ans = tmp // 7 + 1 if tmp % 7 != 0 else 0
    print(ans)

for i in range(int(input())):
    counter = 0
    x = int(input())
    if x // 7 != 0:
        counter += x // 7
        x %= 7
    if x // 6:
        counter += x // 6
        x %= 6
    if x // 5:
        counter += x // 5
        x %= 5
    if x // 4:
        counter += x // 4
        x %= 4
    if x // 3:
        counter += x // 3
        x %= 3
    if x // 2:
        counter += x // 2
        x %= 2
    print(counter)

# https://vjudge.net/contest/319028#problem/F

n = int(input())

for i in range(n):
    t = int(input())
    result = 0
    for i in range(7, 1, -1):
        while t >= i:
            t -= i
            result += 1
    print(result)

for _ in range(int(input())):
    n=int(input())

    if 2<=n<=7:
        print(1)
    else:
        print(n//7)

n = input()

for i in range(n):
        num = input()
        if num % 2 == 0:
                print '2 ' * (num/2)
        else:
                print '2 ' * (num/2-1) + '3'

t = int( input() )
dice_list = [7, 6, 5, 4, 3, 2]
num_list = []

for i in range(t):
	x = int(input())
	num = 0
	if x <= dice_list[0]:
		num_list.append(1)
	else:
		for dice in dice_list:
			num += int(x/dice)
			x %= dice
			if x == 0:
				num_list.append(num)
				break

for num in num_list:
	print(num)

queries = int(raw_input())
numeros = []
tentativas = []
for i in range(queries):
    numeros.append(int(raw_input()))
for i in numeros:
    if i % 7 == 0:
        print i / 7
    elif (i / 7) > 1:
        print (i / 7) + 1
    else:
        print 1

n = input()

for i in range(n):
        num = input()
        if num % 2 == 0:
                print '2 ' * (num/2)
        else:
                print '2 ' * (num/2-1), '3'

for t in range(int(input())):
 s=sorted(input())
 if s[0]==s[-1]:
  print("-1")
 else:
  for i in s:
   print(i)

n = input()
s = tuple(map(int, input().split()))
m = 1e9 + 1
t = 0
for i in s:
    t += i
    if i % 2 and i < m:
        m = i
print((0 if m > 1e9 else t - m) if t % 2 else t)

n=int(input())
w=0
for i in range(n):
    m=int(input())
    while m>7:
        m-=7
        w+=1
    print(w+1)

t=int(input())
a=[]
a=list(map(int , input().split()))

for x in a:
    p=x/2
    c=int(p)
    print(c)

for _ in range(int(input())):
  n = int(input())
  print(n//7+n%7)

x=int(input())
for i in range(x):
    print(int(input())//x)

[[print(str(x) + ": " +str(x // 7 + max(1, x % 7))) for x in [int(input())]] for i in range(int(input()))]

n=int(input())
for i in range(n):
	n1=int(input())
	count=0
	for i in range(7,1,-1):
		if n1!=1:
			count+=int(n1//i)
			n1%=i
		elif n1==1:
			count+=1
		# print(n1)
	print(count)

T = int(input())
for i in range(T):
    n = int(input())
    print(round(n/2))

t=int(input())
while t>0:
    t-=1
    n=int(input())
    print(n//3)

int_=int(input())
for i in range(int_):
    k=int(input())
    num=(k+1)//2
    print(num)

import sys
import math

#to read string
get_string = lambda: sys.stdin.readline().strip()
#to read list of integers
get_list = lambda: list( map(int,sys.stdin.readline().strip().split()) )
#to read non spaced string and elements are integers to list of int
get_intList_from_str = lambda: list(map(int,list(sys.stdin.readline().strip())))
#to read non spaced string and elements are character to list of character
get_strList_from_str = lambda: list(sys.stdin.readline().strip())
#to read integers
get_int = lambda: int(sys.stdin.readline().strip())
#to print faster
pt = lambda x: sys.stdout.write(str(x))

#--------------------------------WhiteHat010--------------------------------------#
for _ in range(get_int()):
    rolls = 0
    n = get_int()
    for i in range(7,1,-1):
        rolls += n//i
        n = n%i
    print(rolls)

for i in range(int(input())):
    x= int(input())
    y= x//7
    if x<=7:
        print(1)
    elif x%7>=2:
        print(y+1)
    else:
        y= x//6
        if x%6>=2:
            print(y+1)

t = int(input())
nums = [int(input()) for i in range(t)]
for k in nums:
	if k%2==0:
	    print(k/2)
	elif k==3:
	    print("1")
	else:
	    print((k-3)/2)

for _ in range(int(input())):
    n = int(input())
    ans = 0
    for i in range(7,1,-1):
        ans += n//i
        n %= i

    if(n):
        print('0')
    else:
        print(ans)

import time

def calculateOptimalRolls(number):
    updN = number
    rolls = 0

    div7 = updN // 7 #rolls futuros
    updN -= div7 * 7

    div6 = updN // 6
    updN -= div6 * 6

    div5 = updN // 5
    updN -= div5 * 5

    div4 = updN // 4
    updN -= div4 * 4

    div3 = updN // 3
    updN -= div3 * 3

    div2 = updN // 2
    updN -= div2 * 2

    rolls = div7 + div6 + div5 + div4 + div3 + div2

    return rolls

def solve():
    queries = int(input())
    for x in range(queries):
        desiredN = int(input())
        print(calculateOptimalRolls(desiredN))

    # print("%fs" % (time.time() - start_time))

solve()

from collections import deque, Counter, OrderedDict
from heapq import nsmallest, nlargest
from math import ceil,floor,log,log2,sqrt,gcd,factorial,pow
def binNumber(n,size=4):
    return bin(n)[2:].zfill(size)

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

def ini():
    return int(input())

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

def sti():
    return str(input())

def par(a):
    return ' '.join(list(map(str,a)))

def tdl(outerListSize,innerListSize,defaultValue = 0):
    return [[defaultValue]*innerListSize for i in range(outerListSize)]

class pair:
    def __init__(self,f,s):
        self.fi = f
        self.se = s
    def __lt__(self,other):
        return (self.fi,self.se) < (other.fi,other.se)

#  =========     /\       /|    |====/|
#      |        /  \       |    |   / |
#      |       /____\      |    |  /  |
#      |      /      \     |    | /   |
#  ========= /        \  =====  |/====|
#  code

if __name__ == "__main__":
    t = ini()
    for _ in range(t):
        x = ini()
        s = 0
        for i in range(7,1,-1):
            s += x//i
            x %= i
        print(s)

t=int(input())
for j in range(t):
    m=int(input())
    c=0
    for i in range(7,1,-1):
        d=m//i
        if((m-(d*i))>=0 and d!=0):
            c+=(d)
            m-=(d*i)
    print(c)

t=int(input())
while t>0:
    t-=1
    n=int(input())
    ans = 0
    if n>=7:
        a = n // 7
        n = n - a*7
        ans += a
    if n>=6:
        a = n // 6
        n = n - a*6
        ans += a
    if n>=5:
        a = n // 5
        n = n - a*5
        ans += a
    if n>=4:
        a = n // 4
        n = n - a*4
        ans += a
    if n>=3:
        a = n // 3
        n = n - a*3
        ans += a
    if n>=2:
        a = n // 2
        n = n - a*2
        ans += a
    print(ans)

for i in range(int(input())):
    print(int(input()))

n = int(input())
count = []
for i in range(n):
    num = int(input())
    if (num/3) == 0:
        count.append(int(num/3))
    else:
        count.append(int(num/3)+1)
for i in range(n):
    print(count[i])

def solve():
    x = int(input())
    ans = 0
    for i in range(7,1,-1):
        ans += x//i
        x = x%i
    print(ans)

t = int(input())
for j in range(t):
    solve()

import random

t=int(input("Enter the no. of queries"))
sum=0
count=0
for i in range(t):
	x=int(input("Enter the sum of number"))
	sum=sum+random.randint(2,7)
		#print("first sum",sum)
	count=count+1
		#print("first count",count)

	while(sum!=x):
		if sum<x:
			sum=sum+random.randint(2,7)
				#print("heyyy",sum)
			count=count+1
			continue

		elif sum>x:

			sum=0
			count=0
				#print("greater than entered")

		else:
			count=count+1
			break

		#print("final", sum)
	print("final count", count)
	sum=0
	count=0

for i in range(int(input())):
	n=int(input())
	flag=0
	for j in range(7,1,-1):
		flag+=n//j
		n=n%j
	print(flag)

for t in range(int(input())):
     x = int(input())
     print(x//2 + (x % 2 == 1))

n = int(input())
for i in range(n):
    score = int(input())
    if score <= 7:
        print(1)
        continue
    else:
        k = score/2
        if score % 2 == 0:
            print(int(k))
        else:
            print(int(k)+1)

"""
Usage:
    python solution.py < input.txt > solution_output.txt

Testing:
    pytest test_solution.py
"""

def get_input(inputs_number: int = 1) -> str:
    """
    Loops throw the stdio to fetch input data
    Args:
        inputs_number: Number of lines of the input
                       Needs to be manually changed in case of
                       multiple lines input
    Returns:
        raw_input_data: The input of a problem
                        It must be equal to the test input on the test file
    """
    raw_input_data = ""
    for _ in range(inputs_number):
        n_tests = input()
        raw_input_data += n_tests + "\n"
        for _ in range(int(n_tests)):
            raw_input_data += input() + "\n"

    return raw_input_data.strip()

def process_input(raw_input_data: str):
    data = raw_input_data.split("\n")
    n_tests = data.pop(0)
    return [int(number) for number in data]

def solve(raw_input_data):
    points = process_input(raw_input_data)
    answer = ""
    for point in points:
        if point % 2 == 0:
           answer += str(point // 2) + "\n"
        else:
            answer += str(((point - 7) // 2) + 1) + "\n"
    return answer

if __name__ == "__main__":

    # while True:
    #     try:
    # Change input lines number here
    input_data = get_input()
    answer = solve(input_data)
    print(answer)
        # except:
        #     break
# number_of_inputs = 1

n = int(raw_input())
for i in range(n):
    m = int(input())
    if m%2 == 0:print(m/2)
    elif m == 1:print(0)
    else: print((m-3)/2)

t = int(input())
k = [2,3,4,5,6,7]
for i in range(t):
	x = int(input())
	if x in k:
		print(x)
	elif x>7 and x%7==0:
		print(x//7)
	elif x>7 and x%7>1:
		print(x//7+1)
	elif x>7 and x%7==1 and x%5==0:
		print(x//5)
	elif x>7 and x%7==1 and x%5>1:
		print(x//5+1)

def solve(num):
    ans = 0
    while num:
        for i in range(7, 1, -1):
            if num - i >= 2:
                num -= i
                ans += 1
            else:
                ans += 1
                num = 0
                break
    return ans

for _ in range(int(input())):
    print(solve(int(input())))

n = int(input())
print(int(int(input())/2) for i in range(n))

t = int(input())

xmin = 2
xmax = 7

for i in range(t):
    x = int(input())
    p = x // 7
    q = x % 7
    if q < 2:
        print(p)
    else:
        print(p+1)

n = int(input())
sum = 0
for i in range(n):
    a = int(input())
    if a >= 7 + 1:
        sum += a // 7
        a = a % 7
    elif a >= 6 + 1:
        sum += a // 6
        a = a % 6
    elif a >= 5 + 1:
        sum += a // 5
        a = a % 5
    elif a >= 4  + 1:
        sum += a // 4
        a = a % 4
    elif a >= 3 + 1:
        sum += a // 3
        a = a % 3
    elif a >= 2 :
        sum += a // 2
        a = a % 2
    print(sum)

for i in range(int(input())):
    a = int(input())
    if a % 2 == 0:
        print(a//2)
    elif a % 2 != 0:
        e = a // 2
        print(e-3)

t = int(input())

xmin = 2
xmax = 7

for i in range(t):
    x = int(input())
    p = x // 7
    q = x % 7
    if q < 3:
        print(p+q)
    elif q > 5:
        print(p+2)
    else:
        print(p+1)

n=int(input())
l=[7,6,5,4,3,2]
for i in range(n):
	a=int(input())
	sum=0
	if a in l:
		print(1)
	else:
		print(a)

def answer():
    n = int(input())
    while n:
        print(int(n/2))
        n-=1
answer()

# Dice Rolling
def dice(x):
    if x <= 7:
        return 1
    if x % 2 == 0:
        return x // 2
    return (x // 2) + 1

t = int(input())
for i in range(t):
    x = int(input())
    print(dice(x))

t = int(input())
k = [2,3,4,5,6,7]
for i in range(t):
	x = int(input())
	if x in k:
		print(1)
	elif x>7 and x%7==0:
		print(x//7)
	elif x>7 and x%7>1:
		print(x//7+1)
	elif x>7 and x%7==1 and x%5==0:
		print(x//5)
	elif x>7 and x%7==1 and x%5>1:
		print(x//5+1)

x = int(input())
for i in range(x):
	a = int(input())
	k = 0
	if x > 7:
		t = int(a/7)
		a = a - a*t
		k = k + t
	elif a > 0:
		a = 0
		k = k + 1
	print(k)

x=int(input())
#no of queries
l=[2,3,4,5,6,7]
z=7
count=0
for i in range(x):
    count=0
    z=7
    y=int(input())
    if y in l:
        print(1)
        continue
    else:
        while y!=0 and z>1:
            m=y//z
            y-=(m*z)
            count+=m
            z-=1
    print (count)

t = int(input())
l = []
for i in range(t):
    x = int(input())
    ans = 0
    for i in range(7,1,-1):
        while(x>=i):
            ans+=1
            x-=i
    print(ans)

n = int(input())
for i in range(n):
    x = int(input())
    print(x/2)

for i in range(int(input())):
    a = int(input())
    if a % 2 == 0:
        print(a//2)
    elif a % 2 != 0:
        e = a // 2
        w = abs(e-3)
        if w == 0:
            print(1)
        else:
            print(w)

t = int(input())
for q in range(t):
            a = int(input())
            if a==2:
                        num = 1
            elif a==3:
                        num = 1
            elif a==4:
                        num = 1
            elif a>4:
                        num = (a//5)+(a%5)
            print(num)

from math import ceil

for _ in range(int(input())):
    n=int(input())
    print(ceil(n/2))

T=int(input())
for i in range(T):
    x=int(input())
    a=x//7
    x=x%7
    b=x//6
    x=x%6
    c=x//5
    x=x%5
    d=x//4
    x=x%4
    e=x//3
    x=x%3
    f=x//2
    print(a+b+c+d+e+f)

x = int(input())
y = [int(input()) for c in range(x)]

for c in range(x):
    print((y[c])//7)

x=int(input())
for i in range(x):
    print(int(input())//x)

x = int(input())
for i in range(x):
	a = int(input())
	k = 0
	if x > 7:
		t = int(a/7)
		a = a - a*t
		k = k + t
	if a > 0:
		a = 0
		k = k + 1
	print(k)

t = int(input())
nums = [int(input()) for i in range(t)]
for k in nums:
	if k%2==0:
	    print(k/2)
	elif k==3:
	    print("1")
	else:
	    print((k-3)/2)

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sat Dec 15 20:59:44 2018

@author: mach
"""

t = int(input())
l = [7,6,5,4,3,2]
for _ in range(t):
    s = 0
    u = int(input())

    for i in l:
        if u >= i :
            if u % i > 1:

                s += u//i
                u = u%i
    print(s)

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon Dec 17 20:47:41 2018

@author: mach
"""

i = int(input())

for _ in range(i):
    o = int(input())
    if o < 3:
        print(o//2)
    print(o//3)


n, m = [int(x) for x in raw_input().split(' ')]
if m <= 1:
    print 1
elif m <= (n / 2):
    print m
else:
    print (n - m)

L  = list(map(int, input().split()))
n = int(L[0])
m = int(L[1])
if m == 1:
    print (1)
elif m  == 0:
    print (1)
elif m == n:
    print (0)
else:
    L = [2 for i in range(n)]
    for i in range(m):
        to_del = L.index(max(L))
        L[to_del] = -1
        if to_del == 0:
            L[1] -= 1
            L[n-1] -= 1
        elif to_del == n - 1:
            L[0] -= 1
            L[n-2] -= 1
        else:
            L[to_del-1] -= 1
            L[to_del+1] -= 1
    zero = L.count(0)
    one = int(L.count(1)/2)
    print (zero + one)

n,m=map(int,input().split())
if(m<=1):
    print("1")
else:
    if(m>n//2):
        print(n-m)
    else:
        print(m)

n, m = input().split()
if(m=="0"):
    print(1)
else:
    print(min(int(m), int(n)-int(m)))

n, m = map(int, input().split())
if m==0:
    print(1)
else:
    if(m>n/2):
        print(n-m)
    else:
        print(m)

n, m = [int(i)for i in input().split(' ')]
def helper(n, m):
    if m <= 1:
        return 1
    if n == m:
        return 0
    return min(m, n-m)

print(helper(n,m))

import sys
input = sys.stdin.readline

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

numbers = input().split()
catsBefore = int(numbers[0])
catsGone = int(numbers[1])
if catsGone == 0:
    print(1)
else:
    if catsGone <= catsBefore // 2:
        print(catsGone)
    else:
        print(catsBefore - catsGone)

from math import floor,ceil

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

hash = {}

for i in range(1,n+1):
    hash[i] = False

count = 0
ans = 1
flag = 0
for i in range(1,n+1,2):

    if count<m:
     count+=1
     hash[i] = True
     if flag!=0 :
         ans+=1
     if count%2 == 0 and flag == 0:
        ans+=1
        flag = 1

if count!=m:

    count+=1

if m <= floor(n/2) and n!=m :

        print(ans)
else:
    print(n-m)

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

print(min(m, n - m) if m != 0 else 1)

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

if m ==0 :

    print(1)

elif m>n//2 :

    print(n-m)

else :

    print(m)

n, m = map(int, input().split())
if m == n:
    print(0)
elif m<=1:
    print(1)
else:
    print(min(m, n-m))

n,m = map(int,input().strip().split())
if m == 0:
    print(1)
elif m == n:
    print(0)
else:
    m -= 1
    n -= 1
    nums = [i for i in range(1,n+1)]
    index = 0
    for i in range(1,n,2):
        if index >= m:
            break
        nums[i] = 0
        index += 1
    if index == 0:
        print(1)
    else:

        if index >= m:
            ans = index
            if index<<1 < len(nums):
                ans += 1
    ##        for i in nums:
    ##            if i == 0:
    ##                ans += 1
        else:
            need = m - index
    ##        if nums[-1] == 0:
    ##            need -= 1
            while need > 0:
                for i in range(len(nums) - 1,-1,-1):
                    if nums[i] != 0:
                        nums[i] = 0
                        break
                need -= 1
            ans = 0
            for i in range(len(nums)):
                if nums[i] != 0:
                    ans += 1
        print(ans)

n,m=map(int,raw_input().split())
if n == 1:
    if m == 0:
        print 1
    else:
        print 0
else:
    if m == 0 or m == 1:
        print 1
    elif n==m:
        print 0
    else:
        print min(m,n-m)
    k=0

n,m = map(int, input().split())
if m==0:
    print(1)
else:
    print(min(n-m, m))

n,m=map(int,input().split())
if m==0:
    print(1)
    exit()
print(min(m,n-m))

import sys
from math import *
from fractions import gcd
readints=lambda:map(int, input().strip('\n').split())

n,m=readints()
if m==0:
    print(1)
elif m<=n//2:
    print(m)
else:
    print(n-m)

#!/usr/bin/env python
"""<https://github.com/cheran-senthil/PyRival>"""
from __future__ import division, print_function

import os
import sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip
else:
    _str = str
    str = lambda x=b"": x if type(x) is bytes else _str(x).encode()

def main():
    n, m = map(int, input().split())
    if m == 0:
        print(1)
    elif m <= n // 2:
        print(m)
    else:
        print(n - m)

# region fastio

BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._buffer = BytesIO()
        self._fd = file.fileno()
        self._writable = "x" in file.mode or "r" not in file.mode
        self.write = self._buffer.write if self._writable else None

    def read(self):
        if self._buffer.tell():
            return self._buffer.read()
        return os.read(self._fd, os.fstat(self._fd).st_size)

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self._buffer.tell()
            self._buffer.seek(0, 2), self._buffer.write(b), self._buffer.seek(ptr)
        self.newlines -= 1
        return self._buffer.readline()

    def flush(self):
        if self._writable:
            os.write(self._fd, self._buffer.getvalue())
            self._buffer.truncate(0), self._buffer.seek(0)

def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", b" "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", b"\n"))
    if kwargs.pop("flush", False):
        file.flush()

sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
input = lambda: sys.stdin.readline().rstrip(b"\r\n")

# endregion

if __name__ == "__main__":
    main()

n, m = [int(t) for t in input().split(' ')]

remaining = n - m

if m > remaining:
    print(remaining)
elif m == 0:
    print(1)
else:
    print(m)

n, m = map(int, input().split())
ans = 1
if m > n // 2:
    print(n - m)
else:
    for i in range(2, m + 1):
        ans += 1
    print(ans)

#code

R = lambda:map(int,input().split())

n, m = R()
print(min(max(m,1),n-m))

vklad = input()
vklad = vklad.split()
myspocet = int(vklad[0])
mysskip = int(vklad[1])
myszostatok = myspocet - mysskip
mysskupina = 0
if myspocet/2 >= mysskip:
	if mysskip == 0:
		mysskip = 1
	mysskupina = mysskip
	print(mysskupina)
elif myspocet/2 < mysskip:
	mysskupina = myspocet-mysskip
	print(mysskupina)

n,m=map(int,raw_input().split())
if m==0:
    print 1
elif n==m:
    print 0
elif m>n//2:
    print n-m
else:
    print m

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

n,m = map(int,input().split())
if m==0:
    print(1)
else:
    print(min(m,n-m))

'''input
3 3
'''
from collections import defaultdict as df
from bisect import bisect_right as bl
import sys

RI = lambda : [int(x) for x in raw_input().split()]
rw = lambda : raw_input().strip()

n,m = RI()
print min(n-m, max(m,1) )

n,m = map(int,input().split())
if(n==m):
    print("0")
elif(m==0):
    print("1")
else:
    print(min(n-m,m))

from sys import stdin, stdout

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

if m == 0:
    print(1)
elif m < n / 2:
    print(m)
else:
    print(n - m)

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

inp=map(int,str(raw_input()).split(" "))
if(inp[1]==0):
    print(1)
elif(inp[0]==inp[1]):
    print(0)
else:
    if(inp[0]//inp[1]>=2):
        print(inp[1])
    else:
        print(inp[0]%inp[1])

n, m = map(int, input().split())
print(min(n - m, max(m, 1)))

import random
import time

seed = int(time.time())
random.seed(seed)

def solve(n, m):
    if m == 0:
        return 1
    if m <= n//2:
        return m
    return n - m

def main():
    xs = [int(x) for x in raw_input().strip().split()]
    print solve(*xs)

if '__main__'==__name__:
    main()

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

def solve(n, m):
	if m == 0:
		return 1
	return min(n-m, m)

n, m = map(int, raw_input().split())
print solve(n, m)

a, b = map(int, input().split())
print(min(max(b, 1), a - b))

n,m=input().split()
if int(m)==0:
  print(1)
elif int(m)<=int(n)/2:
  print(int(m))
else:
  print(int(n)-int(m))

try:
    a,b=map(int,input().split())
    print(min(a-b,max(1,b)))
except:
    print(a)
    print(b)

"""
Author    : raj1307 - Raj Singh
Institute : Jalpaiguri Government Engineering College
Date      : 9.05.19
"""
from __future__ import division, print_function
import itertools,os,sys

from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip
else:
    from builtins import str as __str__
    str = lambda x=b'': x if type(x) is bytes else __str__(x).encode()

BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._buffer = BytesIO()
        self._fd = file.fileno()
        self._writable = 'x' in file.mode or 'r' not in file.mode
        self.write = self._buffer.write if self._writable else None

    def read(self):
        return self._buffer.read() if self._buffer.tell() else os.read(self._fd, os.fstat(self._fd).st_size)

    def readline(self):
        while self.newlines == 0:
            b, ptr = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE)), self._buffer.tell()
            self._buffer.seek(0, 2), self._buffer.write(b), self._buffer.seek(ptr)
            self.newlines += b.count(b'\n') + (not b)
        self.newlines -= 1
        return self._buffer.readline()

    def flush(self):
        if self._writable:
            os.write(self._fd, self._buffer.getvalue())
            self._buffer.truncate(0), self._buffer.seek(0)

sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
input = lambda: sys.stdin.readline().rstrip(b'\r\n')

def print(*args, **kwargs):
    sep, file = kwargs.pop('sep', b' '), kwargs.pop('file', sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop('end', b'\n'))
    if kwargs.pop('flush', False):
        file.flush()

def ii(): return int(input())
def si(): return str(input())
def mi(): return map(int,input().strip().split(" "))
def li(): return list(mi())

#from collections import deque, Counter, OrderedDict,defaultdict
#from heapq import nsmallest, nlargest, heapify, #heappop ,heappush, heapreplace
#from math import ceil,floor,log,sqrt,factorial,pow,pi
#from bisect import bisect_left,bisect_right
#from decimal import *,threading

def dmain():
    sys.setrecursionlimit(100000000)
    threading.stack_size(20480000)
    thread = threading.Thread(target=main)
    thread.start()

abc='abcdefghijklmnopqrstuvwxyz'
abd={'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
mod=1000000007
dx,dy=[-1,1,0,0],[0,0,1,-1]
def getKey(item): return item[0]
def sort2(l):return sorted(l, key=getKey)
def d2(n,m,num):return [[num for x in range(m)] for y in range(n)]
def isPowerOfTwo (x): return (x and (not(x & (x - 1))) )
def decimalToBinary(n): return bin(n).replace("0b","")
def ntl(n):return [int(i) for i in str(n)]
def powerMod(x,y,p):
    res = 1
    x %= p
    while y > 0:
        if y&1:
            res = (res*x)%p
        y = y>>1
        x = (x*x)%p1
    return res
def gcd(x, y):
    while y:
        x, y = y, x % y
    return x

# For getting input from input.txt file
#sys.stdin = open('input.txt', 'r')

# Printing the Output to output.txt file
#sys.stdout = open('output.txt', 'w')

def main():

    n,m=mi()

    if m==0:
        print(1)
        exit()

    print(min(n-m,m))

if __name__ == "__main__":
    main()
    #dmain()

n, m = map(int, raw_input().split())

if m == 0 or m == 1:
	print 1

else:

	m -= 1
	n -= 1
	pares = n/2

	if n % 2  :
		if m <= pares:
			print m + 1

		if pares < m :
			print n - m

	else:
		if m == pares:
			print pares

		if m < pares:
			print m + 1

		if pares < m :
			print n - m

import sys
import math
#q=int(sys.stdin.readline())
q=1
for _ in range(q):
    #n=int(sys.stdin.readline())
    n,m=map(int,sys.stdin.readline().split())
    #a=list(map(str,sys.stdin.readline().split()))
    if m==0:
        print(1)
    else:
        print(min(m,n-m))

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

name = raw_input()   # Python 2.x
(n,m) = name.split(' ')
m = int(m)
n = int(n)
if (m==0):
	print(1)

else:
	print(min(n-m, m))

n,m= map(int,raw_input().split())

if n==m:
    ans = 0
elif m==0 or m==1:
    ans = 1
else:
    ans  = min(m,n-m)
print ans

import math as mm
n,m=map(int,input().split())
if m==0:
    print(1)
else:

    if n%2==0:
        if m<=n//2:
            print(m)
        else:
            print(n-m)
    else:
        if m<=mm.floor(n/2):
            print(m)
        elif m==mm.floor(n/2)+1:
            print(m-1)
        else:
            print(n-m)

n, m = map(int, input().split())
if m < 2:
  print(1)
else:
  print(min(m, n - m))

def f(l):
    n,m = l
    if m<2:
        return 1
    return min(m,n-m)

l  = list(map(int,input().split()))
print(f(l))

# -*- coding:utf8 -*-
# by utoppia
# 09-05-2019

n, m = map(int, raw_input().split(' '))

def f(n, m):
    ans = 1
    if m == 0 :
        return  1
    if m == 1:
        if n > 1:
            return 1
        else:
            return  0

    if m >= 2:
        m -= 2
        n -= 3

    if n <= -1:
        ans = 0
    else:
        p = 1
        left = n
        while m > 0:
            m -= 1
            if left >= 2:
                p += 1
                left -= 2
                if left == 1:
                    p += 1
                    left = 0
            else:
                p -= 1
        ans = p
        if left:
            ans += 1
    return ans

print f(n, m)

import sys
import math
import bisect

def solve(n, m):
    if n == m:
        return 0
    if m == 0 or m == 1:
        return 1
    return min(m, n - m)

def main():
    n, m = map(int, input().split())
    print(solve(n, m))

if __name__ == "__main__":
    main()

line = raw_input().split(' ')
a = int(line[0])
b = int(line[1])

if b == 0:
	print 1
else:
	print min(a - b, b)

n=input().split()
x=int(n[0])
y=int(n[1])
t=x-y
if t==0:
    print(0)
elif y==0:
    print(1)
else:
    bz=0
    for i in range(1,t+1):
        p=t
        p_2=y
        m=0

        while p>0 and p_2!=0:
            p_2-=1
            p-=i
            m+=1
        if m>bz:
            bz=m

    print(bz)

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

if m == 0:
    print(1)
elif m == n:
    print(0)
elif n-m < m:
    print(n-m)
else:
    print(m)

import math
n, m = [int(x) for x in input().split(' ')]
if m == 0:
    print(1)
else:
    print(min(m, n - m))

a, b = map(int, input().split())

if(b == 0):
    print(1)
else:
    print(b if b<= a//2 else a- b)

import os
import sys

# solve
def solve():
    n, m = map(int, input().split())
    print(min(m, n - m) if m != 0 else 1)

# main
if __name__ == "__main__":
    solve()

n, m = [int(x) for x in raw_input().split()]
if m == 0:
    print(1)
else:
    print(min(n-m, m))

n,m=map(int,raw_input().split())
print(n-m if m*2>n else max(m,1))

exit()

n,m=map(int,input().split())
if m!=0:
    if m<=n//2:
        g=m
    else:
        g=n-m
else:
    g=1
print(g)

n, m = map(int, input().split())
if(m == 0):
    print(1)
else:
    print(min(m, n - m))

n, m = map(int, (input().split()))
def max_part(n,m):
    if m>0:
        if n//2 == 0:
            if m <= n//2:
                return m
            else:
                return n-m
        else:
            if m <=(n-1)//2:
                return m
            else:
                return n-m
    else:
        return 1

print(max_part(n,m))

n, m = map(int, raw_input().split())

if n == 0:
    print 0
elif m == 0:
    print 1
else:
    print min(n-m, m)

n,m=map(int,raw_input().split())

if(m==0):
    print 1
elif(m>n/2):
    m=n-m
    print m
else:
    print m

data_input = input().split()

all_cats = int(data_input[0])
leave_cats = int(data_input[1])
real_cats = all_cats - leave_cats

if leave_cats == 0:
    print(1)
elif real_cats == 0:
    print(0)
elif all_cats/2 > leave_cats:
    listik_of_cats = []
    for cat in range(all_cats):
        listik_of_cats.append(cat+1)

    i = 1
    while i < all_cats:
        listik_of_cats[i] = 0
        i += 2
        leave_cats -= 1
        if leave_cats == 0:
            break
        if i > all_cats:
            i = 0

    answer = 0
    for i in range(1,all_cats):
        if listik_of_cats[i] == 0 and listik_of_cats[i-1]:
            answer += 1

    print(answer)
else:
    print(all_cats - leave_cats)

arg = map(int, raw_input().strip().split())

num_of_cat_left = arg[0] - arg[1]

num_of_space = arg[1]

if num_of_space == 0:
	print 1
else:
	if num_of_space > num_of_cat_left:
		print num_of_cat_left
	elif num_of_space == num_of_cat_left:
		print num_of_cat_left
	elif num_of_space < num_of_cat_left:
		print num_of_space

n,m=[int(i) for i in input().split()]
if m==0:
    print(1)
    exit(0)
norm=n//2
should=n-norm
if n%2==1:
    should-=1
    if m>norm:
        norm+=1
res=should-abs(m-norm)
print(res)

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

if n == m:
	print(0)
elif m <= 1:
	print(1)
elif m <= n // 2:
	print(m)
else:
	print(n - m)

n,m = map(int, input().strip().split())
h = n//2
ans = 0
cur = 0
for i in range(1,min(m,h)+1):
    ans += 1
    cur += 1
if m > h and n%2:
    cur += 1
if m > cur:
    for i in range(cur+1,m+1):
        ans-= 1
if m == 0:
    print (1)
else:
    print(ans)

n,m=(int(i) for i in input().split())
if (m==0):
    if (n==0):
        print("0")
    else:
        print("1")
elif (n<=2*m):
    if (m==1):
        if (n==1):
            print("0")
        else:
            print("1")
    elif (m==2):
        if (n<=m):
            print("0")
        elif ((n-m)==1):
            print("1")
        else:
            print("2")
    else:
        if (n<=m):
            print("0")
        else:
            print(n-m)

else:
    if (n<=m):
        print("0")
    else:
        print(m)

n,m=map(int,input().split())
if m==0:
    print(1)
else:
    print(min((n-m),m))

n,k = input().split()
n = int(n)
k = int(k)
num = []
count = 0
for i in range(1,n+1):
    num.append(i)
for i in range(k):
    del num[(i+1)%len(num)]
for i in range(len(num)):
    if num[(i+1)%len(num)] > num[i]+1:
        count+=1
if count == 0 and len(num) > 0:
    count = 1
if len(num) > 1:
    if num[0] != 1 or num[len(num)-1]!=n:
        count += 1
print(count)

n, m = map(int, input().split())
if m * 2 <= n:
	print(max(1, m))
else:
	if n % 2 == 0:
		print(n - m)
	else:
		k = m - n // 2
		if k <= 1:
			print(n // 2)
		else:
			k -= 2
			print(n // 2 - k - 1)

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

#number of cats
n = list[0]
#number of cats who left the circle
m = list[1]

if(m==0) :print(1)
elif(m<=n//2):print(m)
else: print(n-m)

x=input()
x=x.split(' ')
cats_attended=int(x[0])
cats_left=int(x[1])

if int(x[1])==0:
    if int(x[0])!=0:

        print(1)
    else:
        print(0)
else:
    if int(x[0])/int(x[1])>2 or  int(x[0])%int(x[1])==0 and int(x[0])!=int(x[1]) :
        print(int(x[1]))
    else:

        print(int(x[0])-int(x[1]))

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

n, m = list(int(a) for a in input().split())
if m == 0 or m ==1:
    print(1)
elif m == n:
    print(0)
else:
    f = 0
    while n > 2 and m > 0:
        m -= 1
        n -= 2
        f += 1
    if m > 0:
        print(f-m+n)
    else:
        print(f)

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

n, m = map(int, input().split())
print(min(max(1, m), n - m))

# cook your dish here

n,m=[int(i) for i in input().split()]

if(m==0):
    print(1)
else:
    if(n%2==0):
        if(m<=n//2):
            print(m)
        else:
            print(n-m)
    else:
        if(m<=n//2):
            print(m)
        elif(m==n//2+1):
            print(m-1)
        else:
            print(n-m)

import collections, heapq, sys

n, m = map(int, sys.stdin.readline().rstrip().split(' '))
if m == 0:
    print(1)
else:
    print(min(m, n-m))

# -*- coding: utf-8 -*-
"""
Created on Fri May 10 15:31:47 2019

@author: tarushpc
"""
def convert(string):
    return string.split(sep=None,maxsplit=-1)

def toint(lst):
    result=[]
    for i in lst:
        result.append(int(i))
    return result

s=toint(convert(input()))

n=s[0]
m=s[1]

if n==m:
    print(0)
elif m==0 or m==1:
    print(1)
elif n-m>m:
    print(m)
else:
    print(n-m)

n,m=map(int,input().split())
if m==0:
    ans=1
elif m>=n//2:
    ans=n-m
else:
    ans=m
print(ans)

k,n = [int(i) for i in input().split()]
if n==0:
  print(k)
elif k==n:
  print(0)
else:
  print((k-n)//(n-1)+1)

a=list(map(int,input().split()))
b=a[0]-a[1]
if(a[1]==0):
	print(1)
elif(a[1]==1):
	print(1)
else:
	q=int(b/a[1])
	r=int(b%a[1])
	if(a[1]==0):
		print(0)
	elif(q==1):
		print(r)
	else:
		print(q+r)

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

n,m=map(int,input().split())
if(m<=1):
    print("1")
else:
    if(m>=n//2):
        print(n-m)
    else:
        print(m)

n,m = [int(i) for i in input().split()]

print(int(1/2*(1/2*(m+1+abs(m-1))+n-m-abs(2*m-n))))

a,b = list(map(int, input().split()))
r = a-b
if r <= int(a/2):
  print(r)
else:
  print(b)

n,m=map(int,input().split())
if m==0:
    print(1)
elif n%m==0 and n!=m:
    print(m)
elif n//m>=2:
    print((n%m)+1)
elif n//m<=1 and n!=m:
    print(n%m)
elif n==m:
    print(0)

a,b=map(float,raw_input().split())
if(a==b):
	print 0
elif(b==0 or b==1):
	print 1
elif(a/2<b):
	print int(b)
else:
	print int(a-b)

from math import ceil
n,m=map(int,input().split())
if n==0 or n==1:
	print("1")
else:
	n-=3
	m-=2
	print(1+min(ceil(n/2),m))

data_input = input().split()

all_cats = int(data_input[0])
leave_cats = int(data_input[1])
real_cats = all_cats - leave_cats

if leave_cats == 0:
    print(1)
elif real_cats == 0:
    print(0)
else:
    i = 2
    n = real_cats
    while i <= n/2:
        if n%i == 0:
            n = i
            i = 2
        i += 1

    print(n)

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

a = [i for i in range(1, 1 + n)]
if (n % 2 == 0):
    for i in range(1, 1 + n):
        if i % 2 == 0 and m > 0:
            a[i - 1] = 0
else:
    for i in range(1, 1 + n):
        if i % 2 != 0 and m > 0:
            a[i - 1] = 0

cnt = 0
i = 0
ans = 0
while i < n:
    if a[i] != 0:
        cnt += 1
    else:
        if cnt != 0:
            ans += 1
    i += 1

if (a.count(0) == 0):
   ans += 1

print(ans)

from math import ceil
n,m = map(int,input().split())
if m==0 or m==1:
    print(1)
    exit()
if m==n:
    print(0)
    exit

print(ceil(m/2)+1)
#for i in range(m)

def fun(n,m):
    if n == 1 and m == 1:
        return 0
    if n == 1 and m  > 1:
        return 0
    if m == 0:
        return 0
    if m == 1:
        return 1
    p=n
    k =0
    while p > 1:
        p=p/2
        k += 1
    return min(n-m,fun(n-pow(2,k),m-k)+k)
n,m=map(int,raw_input().split())
check = []
if m == 0:
    print 1
elif m == n:
    print 0
else:
    ans=fun(n,m)
    print ans

n, m = list(int(a) for a in input().split())
if m == 0 or m ==1:
    print(1)
elif m == n:
    print(0)
else:
    f = 0
    while n > 2 and m > 0:
        m -= 1
        n -= 2
        f += 1
    print(f)

noOfCat,catLeft=input().split(" ")
noOfCat=int(noOfCat)
catLeft=int(catLeft)
noOfCat
priorityQue=[]
priorityQue.append(noOfCat-1)
catCounter=catLeft-1
if catLeft==0:
    print(1)
elif catLeft==1:
    print(1)
elif catLeft>=2:
    while catCounter>0:
        priorityQue.sort()
        tmp=priorityQue.pop()
        grpsplit1=tmp//2
        grpsplit2=tmp-grpsplit1-1
        if grpsplit1>grpsplit2:
            if grpsplit2!=0 :
                priorityQue.append(grpsplit2)
            if grpsplit1!=0 :
                priorityQue.append(grpsplit1)
        else:
            if grpsplit1!=0 :
                priorityQue.append(grpsplit1)
            if grpsplit2!=0 :
                priorityQue.append(grpsplit2)
        catCounter-=1
    print(priorityQue.__len__())

import math
from fractions import Fraction as frac

MOD = 1e9 + 7

def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)

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

def solve(case_no):
    n, m = map(int, input().split())
    print(n - max(m, n - m))

t = 1
# t = int(input())
for i in range(1, t + 1):
    solve(i)

a,b=[int(i) for i in input().split()]
l=[1]*a
if(b==0):
    print(1)
elif(a==b):
    print(0)
else:
    for i in range(0,len(l),2):
        l[i]=0
        if(l.count(0)==b):
            break
    flag=0
    c=0
    for i in range(0,len(l)):
        if(l[i]==1):
            if(flag==1):
                flag=0
                c=c+1
            else:
                pass
        elif(l[i]==0):
            flag=1
    print(c)

n, m = [int(i) for i in input().split()]

if n % 2 == 0:
    if m <= n / 2:
        res = m
    else:
        res = n - m
else:
    if m <= n // 2 + 1:
        res = m
    else:
        res = n - m

print(res)

ent=input().split()  #taking the input
l1=int(ent[0])
l2=int(ent[1])
if(l1<=1000 and l1<=0 and l2<=0):
    if l2==0:
        group=1
    elif l2==l1:
        group=0
    else:
        members=int((l1-l2)/2)
        group=int((l1-l2)/members)
    print(group)

import math
n,m=map(int,input().split())
print(min(n-m,1+(m//2)))

#!/usr/bin/env python3
import atexit
import io
import sys

_I_B = sys.stdin.read().splitlines()
input = iter(_I_B).__next__
_O_B = io.StringIO()
sys.stdout = _O_B

@atexit.register
def write():
    sys.__stdout__.write(_O_B.getvalue())

def main():
    n,m=map(int,input().split())
    if n==m:
        print(0)
    elif m==0 or m==1:
        print(1)
    else:
        print(min(n//2,n-m))

if __name__=='__main__':
    main()

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

full = n // 2 + n % 2

print(n // 2 - max(0, m - full))

n,m=(int(i) for i in input().split())
if (n<=10):
    if (m==0):
        print("1")
    elif (m==1):
        if (n==1):
            print("0")
        else:
            print("1")
    elif (m==2):
        if (n<=m):
            print("0")
        else:
            print("2")
    else:
        if (n<=m):
            print("0")
        else:
            print(n-m)

else:
    if (n<=m):
        print("0")
    else:
        print(m)

try:
    a,b=map(int,input().split())
    l=a-b
    if not b:
        print(1)
    else:
        if l/b<1:
            print(l)
        else:
            if l/b==l//b:
                print(l//b)
            else:
                print((l//b)+1)
except:
    print(a)
    print(b)

#!/usr/bin/env python3
import atexit
import io
import sys

_I_B = sys.stdin.read().splitlines()
input = iter(_I_B).__next__
_O_B = io.StringIO()
sys.stdout = _O_B

@atexit.register
def write():
    sys.__stdout__.write(_O_B.getvalue())

def main():
    n,m=map(int,input().split())
    if n==m:
        print(0)
    elif m==0 or m==1:
        print(1)
    else:
        print(min(n//2,m))

if __name__=='__main__':
    main()

n, m = list(map(int, input().split()))
if m == 0:
    print(1)
    exit()
print(min(m + 1, n - m))

n,m=[int(x) for x in input().split()]
if m==0:
    print(0)
else:
    if m-1>n//2:
        print(n-m)
    else:
        print(m)

import math

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

def main():
    global m,n

    if m == n:
        return 0
    elif m == n-1:
        return 1
    elif m == 0 or m == 1:
        return 1
    else:
        required = math.ceil(n/2)

        if m >= required:
            return math.trunc(n/2) - (m - required)

        if n % 2 and m == required - 1:
            m -= 1

        return m

print(main())

n, m = map(int,input().split())
ans = n // 2 - abs(m - n // 2)
if n % 2 != 0:ans += 1
print(ans)

from math import ceil
n,m = map(int,input().split())
if m==0 or (m==1 and n!=1):
    print(1)
    exit()
if m==n:
    print(0)
    exit()

#print(ceil(m/2)+1)

c = 1
for i in range(0,m,2):
    c+=1
print(c)

n, m = list(map(int, input().split()))
print(min(m + 1, n - m))

n, m = map(int, input().split())
if n >= 2 * m:
    print(m)
else:
    print(n - m)

inp = input().split()
n = int(inp[0])
m = int(inp[1])

if 2*m <= n:
	print(m)
else:
	print(n-m)

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

if n == m:
    print(0)
elif m == 0:
    print(1)
elif n % m == 0:
    print(2)
else:
    print(3)

n,m=map(int,input().split())
c=1
l=[1]*n
c=0
i=0
if m==n:
    print(0)
else:

    while(c<m):
        l[i%n]=0
        i=i+2
        c+=1
    k=0
    for i in range(n):
        if len(set(l))==1 and l[0]==1:
            k=1
        elif l[i%n]==1 and l[(i+1)%n]==0 :
            k=k+1
        else:
            k=k
    print(k)
    #print(l)

def ans(n, m):
    if m == 0:
        return 1
    if n == m:
        return 0
    if m < n / 2:
        return m

    return n - m
n, m = map(int, raw_input().split())
print(ans(n, m))

a,b = list(map(int, input().split()))
r = a-b
if r <= int(a/2):
  print(r)
else:
  print(b)

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

if n==m:
    print(0)
elif m<n//2:
    if m==0:
        print(1)
    else:
        print(m)
else:
    print(m-1)

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

if n == m:
    print(0)
elif m == 0:
    print(1)
else:
    mid = n // 2
    if m >= mid:
        print(n - m)
    else:
        print(m)

import sys
n, m = [int(x) for x in input().split()]
out=0

if(float(m)<n/2 and float(m)>0):
	out=m
elif(float(m)>n/2):
	out=n-m
elif(m==0):
	out=1

print(out)

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

if n == m:
    print(0)
elif m == 0:
    print(1)
elif m == 1:
    print(n - 1)
else:
    if n % 2 != 0:
        print(n - m)
    elif n % 2 == 0 and m % 2 == 0:
        print(2)
    else:
        print(n - 1)

L  = list(map(int, input().split()))
n = int(L[0])
m = int(L[1])
if m == 1:
    print (1)
elif m  == 0:
    print (1)
elif m == n:
    print (0)
else:
    L = [2 for i in range(n)]
    for i in range(m):
        to_del = L.index(max(L))
        L[to_del] = -1
        if to_del == 0:
            L[1] -= 1
            L[n-1] -= 1
        elif to_del == n - 1:
            L[0] -= 1
            L[n-2] -= 1
        else:
            L[to_del-1] -= 1
            L[to_del+1] -= 1
    two = L.count(2)
    zero = L.count(0)
    #print (L)
    if two == 0:
        one = int(L.count(1)/2)
    else:
        one = 0
    #print (zero,one,two)
    print (zero + one + two)

try:
    a,b=map(int,input().split())
    l=a-b
    if not b and b==True:
        print(1)
    else:
        if l/b<1:
            print(l)
        else:
            if l/b==l//b:
                print(l//b)
            else:
                print((l//b)+1)
except:
    print(a)
    print(b)

import math
n,m=map(int,input().split())
if (m == n):
  print(0)
elif (2 * m > n):
  print(m-1)
elif (m == 0):
  print(1)
else:
  print(m)

n, m = map(int, input().split())
if(m > int(n/2)):
    print(n - m)
else:
    print(m)

from numbers import Number
import math

fuck = None
input2 = None
s = None
inputs = None
i = None
n = None
m = None
answer = None

def text_prompt(msg):
  try:
    return raw_input(msg)
  except NameError:
    return input(msg)

input2 = text_prompt('')
inputs = input2.split(' ')
n = int(inputs[0])
m = int(inputs[1])
# print(m,n)
if n <= m or m == 0:
  answer = 0
else:
  # print('A')
  if n < m * 2:
    m = n - m
    # print('B')
  answer = m
print(answer)

n,m = map(int,input().strip().split())
if m == 0:
    print(1)
elif m == n:
    print(0)
else:
    m -= 1
    n -= 1
    nums = [i for i in range(1,n+1)]
    index = 0
    for i in range(1,n,2):
        if index >= m:
            break
        nums[i] = 0
        index += 1
    if index == 0:
        print(0)
    else:

        if index >= m:
            ans = index + 1 if len(nums) % 2 != 0 else index
    ##        for i in nums:
    ##            if i == 0:
    ##                ans += 1
        else:
            need = m - index
    ##        if nums[-1] == 0:
    ##            need -= 1
            while need > 0:
                for i in range(len(nums) - 1,-1,-1):
                    if nums[i] != 0:
                        nums[i] = 0
                        break
                need -= 1
            ans = 0
            for i in range(len(nums)):
                if nums[i] != 0:
                    ans += 1
        print(ans)

n, m = map(int, raw_input().split())

if m == 0:
    print 1
    exit()
if m == 1:
    print 1

if 2*m >= n:
    print n-m
else:
    print n-m-2

n, m = map(int, input().split())
# n, m = map(int, '3 0'.split())

def foo(n, m):
    if n == m:
        return 0
    elif m == 0:
        return 1
    elif m > n / 2:
        return n - m
    else:
        return int(n / 2 - 1)

print(foo(n, m))

n=input().split()
x=int(n[0])
y=int(n[1])
t=x-y
bz=1
for i in range(1,t+1):
    p=t
    p_2=y
    m=0

    while p>0 and p_2!=0:
        p_2-=1
        p-=i
        m+=1
    if m>bz:
        bz=m
print(bz)

from numbers import Number
import math

fuck = None
input2 = None
s = None
inputs = None
i = None
n = None
m = None

def text_prompt(msg):
  try:
    return input(msg)
  except NameError:
    return input(msg)

input2 = text_prompt('')
inputs = input2.split(' ')
n = inputs[0]
m = inputs[1]
print(m if n >= m * 2 else (0 if n <= m else math.floor(n / 2) - (m - math.ceil(n / 2))))

inp=map(int,str(raw_input()).split(" "))
if(inp[1]==0):
    print(1)
elif(inp[0]//inp[1]>2):
    print(inp[0]//inp[1]-1)
else:
    print(inp[0]-inp[1])

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

t = [True] * n
j = 0
for i in range(1, n, 2):
    t[i] = False
    j += 1
    if j == m:
        break

for i in range(n):
    if t[i]:
        t[i] = False
        j += 1
        if j == m:
            break

i = 0
c = 0
while i < n:
    if t[i]:
        c += 1
        while i < n and t[i]:
            i += 1
    else:
        i += 1
print(c)

n,m=map(int,input().split())
if m!=0:
    if m<n//2:
        g=m
    else:
        g=n-m
else:
    g=1
print(g)

n, m = map(int, input().split())
print(min(n - m, max(m - 1, 0)))

inp = input().split()
n = int(inp[0])
m = int(inp[1])

if 2*m <= n:
	print(m)
else:
	print(n-m)

n,m=map(int,input().split())
if m==0:
    print(1)
elif (n-m)%2==0:
    print((n-m)//2)
else:
    print(n-m)

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

if n == m:
    print(0)
elif m == 0:
    print(1)
elif n % 2 != 0 and m % 2 == 0:
    print(m)
else:
    print(m - n)

data = [int(i) for i in input().split()]
cats_plots_num = []
cats_leave = 0
for cats in range(1, data[0] + 1, 2):
    if (cats_leave == data[0] - data[1] or data[1] == 0):
        break
    cats_plots_num += [cats]
    cats_leave += 1
print(len(cats_plots_num))

n,m=map(int,input().split())
l=[1]*(n)
i=0
for _ in range(m):
    l[i%n]=0
    i=i+2
flag=True
if m==0:
    if n==0:
        print(0)
    else:
        print(1)
elif n==m:
    print(0)
else:
    c=0
    for i in range(n-1):
        if flag:
            if l[i]==0:
                c=c+1
                flag=False
        else:
            if l[i]==1:
                flag=True
    print(c)

a,m=list(map(int,input().split()))

if a%2==0:
    if m==0:
        print(a)
    elif 0<m<=a//2:
        print(m)
    elif a//2<m<a:
        print(a//2-m%(a//2))
    else:
        print(0)
else:
    if m==0:
        print(a)
    elif m<=a//2:
        print(m)
    elif m==a//2+1:
        print(a//2)
    elif a//2+1<m<a:
        print(a//2-(m%(a//2)-1))
    else:
        print(0)

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

n,m=map(int,input().split())
c=1
l=[1]*n
if m<n//2:
    for i in range(0,n,2):
        l[i%n]=0
    print(sum(l)-1)
else:
    for i in range(0,n,2):
        l[i%n]=0
    print(sum(l))

"""
    Satwik_Tiwari ;) .
    24th Sept , 2020  - Thursday
"""

#===============================================================================================
#importing some useful libraries.

from __future__ import division, print_function
from fractions import Fraction
import sys
import os
from io import BytesIO, IOBase

# from itertools import *
# from heapq import *
from math import gcd, factorial,floor,ceil

from copy import deepcopy
from collections import deque

# from collections import Counter as counter  # Counter(list)  return a dict with {key: count}
# from itertools import combinations as comb # if a = [1,2,3] then print(list(comb(a,2))) -----> [(1, 2), (1, 3), (2, 3)]
# from itertools import permutations as permutate

from bisect import bisect_left as bl
from bisect import bisect_right as br
from bisect import bisect

#==============================================================================================
#fast I/O region
BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)

class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")

def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()

if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)

# inp = lambda: sys.stdin.readline().rstrip("\r\n")

#===============================================================================================
### START ITERATE RECURSION ###
from types import GeneratorType
def iterative(f, stack=[]):
  def wrapped_func(*args, **kwargs):
    if stack: return f(*args, **kwargs)
    to = f(*args, **kwargs)
    while True:
      if type(to) is GeneratorType:
        stack.append(to)
        to = next(to)
        continue
      stack.pop()
      if not stack: break
      to = stack[-1].send(to)
    return to
  return wrapped_func
#### END ITERATE RECURSION ####

#===============================================================================================
#some shortcuts

mod = 10**9+7
def inp(): return sys.stdin.readline().rstrip("\r\n") #for fast input
def out(var): sys.stdout.write(str(var))  #for fast output, always take string
def lis(): return list(map(int, inp().split()))
def stringlis(): return list(map(str, inp().split()))
def sep(): return map(int, inp().split())
def strsep(): return map(str, inp().split())
# def graph(vertex): return [[] for i in range(0,vertex+1)]
def zerolist(n): return [0]*n
def nextline(): out("\n")  #as stdout.write always print sring.
def testcase(t):
    for pp in range(t):
        solve(pp)
def printlist(a) :
    for p in range(0,len(a)):
        out(str(a[p]) + ' ')
def google(p):
    print('Case #'+str(p)+': ',end='')
def lcm(a,b): return (a*b)//gcd(a,b)
def power(x, y, p) :
    res = 1     # Initialize result
    x = x % p  # Update x if it is more , than or equal to p
    if (x == 0) :
        return 0
    while (y > 0) :
        if ((y & 1) == 1) : # If y is odd, multiply, x with result
            res = (res * x) % p

        y = y >> 1      # y = y/2
        x = (x * x) % p
    return res
def ncr(n,r): return factorial(n) // (factorial(r) * factorial(max(n - r, 1)))
def isPrime(n) :
    if (n <= 1) : return False
    if (n <= 3) : return True
    if (n % 2 == 0 or n % 3 == 0) : return False
    i = 5
    while(i * i <= n) :
        if (n % i == 0 or n % (i + 2) == 0) :
            return False
        i = i + 6
    return True

#===============================================================================================
# code here ;))

def solve(case):
    n,m = sep()
    if(n == m):
        print(0)
        return

    if(m<n//2):
        print(max(m,1))
    else:
        print(max(n-m,1))

testcase(1)
# testcase(int(inp()))

k,n = [int(i) for i in input().split()]
if n==0:
  print(k)
elif k==n:
  print(0)
else:
  print((k-n)//(n-1)+1)

def solve(n, m):
	return max(0, min(n-m, m))

n, m = map(int, raw_input().split())
print solve(n, m)

import math
n, m = [int(x) for x in input().split(' ')]
if m == 0:
    print(1)
else:
    c = [n - 1]
    for i in range(m - 1):
        x = c[-1]
        if x == 2:
            c.insert(0, 1)
        elif x > 2:
            c.insert(0, math.ceil((x - 1) / 2))
            c.insert(0, math.floor((x - 1) / 2))
            c.sort()
        del c[-1]
    print(len(c))

n,m = (int(i) for i in input().split())
if(m == 0):
    print(1);
if m < (n/2):
    print(m);
elif m == (n/2):
    print(m);
else:
    print(n - m);

import math
n,m=map(int,input().split())
print(min(n-m,1+(m//2)))

import sys
range = xrange
input = raw_input

n,m = [int(x) for x in input().split()]

k = m

A = [False]*n
i = 0
while k and i<n:
    A[i] = True
    i += 2
    k -= 1

i = 1
while k and i<n:
    A[i] = True
    i += 2
    k -= 1

A.append(A[-1])
count = 0
for i in range(n):
    if A[i] and not A[i-1]:
        count += 1
print count

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

if n == m:
    print(0)
elif m == 0:
    print(1)
else:
    mid = n // 2
    if m >= mid:
        print(n - m)
    else:
        print(m)

R = lambda:map(int, raw_input().split())
L = R()
n = L[0]
m = L[1]
print(min(m, n-m))

b = input().split()
n, m = int(b[0]), int(b[1])
if m == 0 or m==1 or m==n-1:
    a = 1
elif m == n:
    a = 0
elif m==2:
    a = 2
else:
    a = min([m+1, n-m])
print(a)

x,y=map(int,input().split())
k=x%2
x-=k
y-=k
m=x//2
if y<=1:print(1)
else:
	if y<=m:
		print(y)
	else:
		print(2*m-y)

n,m=map(int, raw_input().split())
if m!=0:
    if n/2<=m:
        print n-m
    else:
        print m
else:
    print 1

n,m=[int(x) for x in input().split()]
if m==0:
    print(0)
else:
    if m-1>=n//2:
        print(n-m)
    else:
        print(m)

from sys import stdin,stdout
from collections import Counter
def ai(): return list(map(int, stdin.readline().split()))
def ei(): return map(int, stdin.readline().split())
def ip(): return  int(stdin.readline().strip())
def op(ans): return stdout.write(str(ans) + '\n')

n,k = ei()
print(1 if k==0 else min(n,n-k))

n,m = map(int,input().split())
if m<=n//2:
    ans = m
else:
    ans = n//2
    m-=n//2
    if n%2==0:
        ans-=m
    else:
        ans-=m-1
print(ans)

n, m = map(int, input().strip().split())
print((n-m)//2)

n, m = map(int, input().split())
if n >= 2 * m:
    print(m)
else:
    print(n - m)

data_input = input().split()

all_cats = int(data_input[0])
leave_cats = int(data_input[1])
real_cats = all_cats - leave_cats

if leave_cats == 0:
    print(1)
elif real_cats == 0:
    print(0)
else:
    listik_of_cats = []
    for cat in range(all_cats):
        listik_of_cats.append(cat+1)

    i = 1
    while i < all_cats:
        listik_of_cats[i] = 0
        i += 2
        leave_cats -= 1
        if leave_cats == 0:
            break
        if i > all_cats:
            i = 0

    answer = 0
    for i in range(1,all_cats):
        if listik_of_cats[i] == 0 and listik_of_cats[i-1]:
            answer += 1

    print(answer)

s=input()
n,m=int(s[0]),int(s[2])
if m==0:
    print(1)
elif m==n:
    print(0)
elif n//m>=2:
    print(m)
else:
    print(n-m)

ent=input().split()  #taking the input
m=int(ent[0])
n=int(ent[1])
if m<=1000 and m>=0 and n>=0:
    if n==0:
        group=1
    elif m-1<(n/2):
        group=m
    elif (m+1)>=(n/2):
        group=n-m
    print(group)

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

a = [i for i in range(1, 1 + n)]
if (n % 2 == 0):
    for i in range(1, 1 + n):
        if i % 2 == 0 and m > 0:
            a[i - 1] = 0
else:
    for i in range(1, 1 + n):
        if i % 2 != 0 and m > 0:
            a[i - 1] = 0

cnt = 0
i = 0
while i < n:
    if a[i] == 0 and i != n - 1:
        cnt += 1
    i += 1

if (a.count(0) == 0):
   cnt += 1

print(cnt)

from numbers import Number
import math

fuck = None
input2 = None
s = None
inputs = None
i = None
n = None
m = None
answer = None

def text_prompt(msg):
  try:
    return raw_input(msg)
  except NameError:
    return input(msg)

input2 = text_prompt('')
inputs = input2.split(' ')
n = int(inputs[0])
m = int(inputs[1])
# print(m,n)
if n <= m:
  answer = 0
else:
  # print('A')
  if n < m * 2:
    m = n - m
    # print('B')
  answer = m
print(answer)