import std.stdio;
import std.algorithm;
import std.math;
import std.conv;
import std.string;

T readNum(T)(){
  return readStr.to!T;
}

T[] readNums(T)(){
  return readStr.split.to!(T[]);
}

string readStr(){
  return readln.chomp;
}

void main(){
  int[] nk = readNums!int[];

  if(nk[1] == 1){
    writeln("0");
  } else {
    nk[0] -= nk[1];
    writeln(nk[0]);
  }
}
