import math

ns = input()
n = int(ns)
k = int(input())

# 10ごとに 9
# 100ごとに81
# 1000ごとに890


small = 10 ** (k - 1)
if n < small:
    print(0)
    exit()

ans = n / (10 ** 1) * 9 - (9 - int(n / (10 ** (len(ns) - 1))))
