# diverta2019-2A - Ball Distribution
def main():
    n, k = map(int, input().rstrip().split())
    print(n % k)


if __name__ == "__main__":
    main() def main():
    n, k = map(int, input().rstrip().split())
    print(n % k) main n, k = map(int, input().rstrip().split()) n map(int, input().rstrip().split()) map int input().rstrip().split() ().rstrip().split ().rstrip() ().rstrip () input rstrip split k print(n % k) print n % k n k if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main def main():
    n, k = map(int, input().rstrip().split())
    print(n % k) def main():
    n, k = map(int, input().rstrip().split())
    print(n % k) main
# diverta2019-2A - Ball Distribution
def main():
    n, k = map(int, input().rstrip().split())
    print(n % k)


if __name__ == "__main__":
    main()