def main(): n, k = map(int, input().split()) if n % 2 == 0: print(min(n // 2, k + 1)) else: print(min(n, k + 1)) if __name__ == "__main__": main()