def main():
    N,K = map(int,input().split())
    print(N-(N//K)*K)
if __name__ == '__main__':
    main() def main():
    N,K = map(int,input().split())
    print(N-(N//K)*K) main N,K = map(int,input().split()) N map(int,input().split()) map int input().split() ().split () input split K print(N-(N//K)*K) print N-(N//K)*K N (N//K)*K N//K N K K if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main def main():
    N,K = map(int,input().split())
    print(N-(N//K)*K) def main():
    N,K = map(int,input().split())
    print(N-(N//K)*K) main
def main():
    N,K = map(int,input().split())
    print(N-(N//K)*K)
if __name__ == '__main__':
    main()