import std.algorithm;
import std.array;
import std.bitmanip;
import std.conv;
import std.stdio;
import std.string;
import std.typecons;

T diff(T)(const ref T a, const ref T b) { return a > b ? a - b : b - a; }

void main() {
    immutable ip = readln.split.to!(ulong[]);
    immutable n = ip[0], k = ip[1];

    ulong ret = k == 1 ? 0 : n-k;
    writeln(ret);
}
