def main():
    balls, people = map(int, input().split())
    print(0 if people == balls or people == 1 else balls - people)


if __name__ == '__main__':
    main()
 def main():
    balls, people = map(int, input().split())
    print(0 if people == balls or people == 1 else balls - people) main balls, people = map(int, input().split()) balls map(int, input().split()) map int input().split() ().split () input split people print(0 if people == balls or people == 1 else balls - people) print 0 if people == balls or people == 1 else balls - people people == balls or people == 1 people == balls people balls people == 1 people 1 0 balls - people balls people if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main def main():
    balls, people = map(int, input().split())
    print(0 if people == balls or people == 1 else balls - people) def main():
    balls, people = map(int, input().split())
    print(0 if people == balls or people == 1 else balls - people) main
def main():
    balls, people = map(int, input().split())
    print(0 if people == balls or people == 1 else balls - people)


if __name__ == '__main__':
    main()

