#include<bits/stdc++.h>
using namespace std;
#define pi acos(-1)
#define first f
#define second s
#define long long ll
#define Max 100005

//int arr[]
//char s[]

int main ()
{
    int n, k;
    cin >> n >>k;
    int e = n - k;
    if (k > 1) printf ("%d", e);
    else printf ("0");
    return 0;
}
