Problem:
Score : 100 points

Problem Statement

Takahashi is distributing N balls to K persons.

If each person has to receive at least one ball, what is the maximum possible difference in the number of balls received between the person with the most balls and the person with the fewest balls?

Constraints

1 \leq K \leq N \leq 100

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N K

Output

Print the maximum possible difference in the number of balls received.

Sample Input 1

3 2

Sample Output 1

1

The only way to distribute three balls to two persons so that each of them receives at least one ball is to give one ball to one person and give two balls to the other person.

Thus, the maximum possible difference in the number of balls received is 1.

Sample Input 2

3 1

Sample Output 2

0

We have no choice but to give three balls to the only person, in which case the difference in the number of balls received is 0.

Sample Input 3

8 5

Sample Output 3

3

For example, if we give 1, 4, 1, 1, 1 balls to the five persons, the number of balls received between the person with the most balls and the person with the fewest balls would be 3, which is the maximum result.

Solution in Python (3.4.3) (judge verdict: Runtime Error)

#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <iterator>
#include <cmath>

using namespace std;

template<class A0>
void input(A0 &a0) { cin>>a0; }
template<class A0, class A1>
void input(A0 &a0, A1 &a1) { cin>>a0>>a1; }
template<class A0, class A1, class A2>
void input(A0 &a0, A1 &a1, A2 &a2) { cin>>a0>>a1>>a2; }
template<class A0, class A1, class A2, class A3>
void input(A0 &a0, A1 &a1, A2 &a2, A3 &a3) { cin>>a0>>a1>>a2>>a3; }
template<class A0, class A1, class A2, class A3, class A4>
void input(A0 &a0, A1 &a1, A2 &a2, A3 &a3, A4 &a4) { cin>>a0>>a1>>a2>>a3>>a4; }
template<class C,class T,class Arr>
basic_istream<C,T>&operator>>(basic_istream<C,T>&is,Arr&arr){for(auto&e:arr)is>>e;return is;}

template<class A0>
void print(A0 const &a0) {cout<<a0<<endl;}
template<class A0, class A1>
void print(A0 const&a0,A1 const&a1) {cout<<a0<<" ";print(a1);}
template<class A0, class A1, class A2>
void print(A0 const &a0, A1 const&a1, A2 const&a2) {cout<<a0<<" ";print(a1,a2);}
template<class A0,class A1,class A2,class A3>
void print(A0 const&a0,A1 const&a1,A2 const&a2,A3 const&a3){cout<<a0<<" ";print(a1,a2,a3);}
template<class A0,class A1,class A2,class A3, class A4>
void print(A0 const&a0,A1 const&a1,A2 const&a2,A3 const&a3, A4 const&a4){cout<<a0<<" ";print(a1,a2,a3,a4);}
template<class C,class T,class Arr>
basic_ostream<C,T>& operator<<(basic_ostream<C,T>& os,Arr const&arr) {
  os<<"[";for(auto i=arr.begin(),e=arr.end();i!=e;os<<((++i!=e)?",":"]"))os<<*i;return os;
}

using lli = long long int;
lli gcd(lli const p, lli const q) { return q == 0 ? p : gcd(q, p%q); }
lli pow(lli const a, lli const n, lli const m){return(!n)?1:(n&1)?(((a%m)*pow(a,n-1,m))%m):[=](){lli b=pow(a,n/2,m);return(b*b)%m;}();}
lli inv(lli const a, lli const p) { return pow(a, p-2, p); }



int main()
{
  int N,K;
  input(N,K);
  if (1 == K) print(0);
  else print(N - K);
}