#include <iostream>
#include <cstring> 
using namespace std;

int main() {
	// your code goes here
	int b=0, c;
	string a;
	cin>>a>>c;
	for(int i=0; i<a.size(); i++) {b=b*10+a[i]-48; if(b>c) b=b%c;}
	cout<<b<<endl<<a.size();
	return 0;
}