#include<iostream> using namespace std; int main(){ long long a,b,c; cin>>a>>c; b=c%10; cout<<a%c<<endl; cout<<a%b; return 0; }