'use strict';
(function(input){
  input=input.trim().split(/\s+/).map(x=>x-0);
  if(input[1]===1){
    console.log(0);
    return;
  }else{
    console.log(input[0]-input[1]);
  }
})(require('fs').readFileSync('/dev/stdin','utf8'));