#include<bits/stdc++.h> using namespace std; int main(){ unsigned long long a,b,t,n; cin>>a>>b; t=b%a; cout<<t; return 0; }