#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#define sz(x) (int)(x).size()
using namespace std;
typedef vector<int> vi;
vi add(vi a, vi b) { //StatusOk
if (a.size() < b.size()) return add(b, a);
vi c(max(sz(a), sz(b)) + 1);
for (int i = 0; i < sz(a); ++i) {
c[i] += a[i];
if (i < sz(b)) c[i] += b[i];
c[i+1] += c[i] / 10;
c[i] %= 10;
}
while (c.size() > 1 and not c.back()) c.pop_back();
return c;
}
vi mul(vi a, vi b) { //StatusOk in ybt but wrong in fzl
vi c(a.size() + b.size() + 1);
for (int i = 0; i < (int)a.size(); ++i) {
for (int j = 0; j < (int)b.size(); ++j) {
c[i+j] += a[i] * b[j];
c[i+j+1] += c[i+j] / 10;
c[i+j] %= 10;
}
}
while(c.size() > 1 and not c.back()) c.pop_back();
return c;
}
vi sub(vi a, vi b) { //StatusOk
vi c;
for (int i = 0, t = 0; i < (int)a.size(); ++i) {
t = a[i] - t;
if (i < (int)b.size())
t -= b[i];
c.push_back((t + 10) % 10);
if (t < 0) t = 1;
else t = 0;
}
while(c.size() > 1 and not c.back()) c.pop_back();
return c;
}
int cmp(const vi &a, const vi &b) { //a less b return 1
if (a.size() == b.size()) {
for (int i = a.size() - 1; ~i; --i)
if (a[i] < b[i]) return 1;
else if (a[i] > b[i]) return -1;
} else return a.size() < b.size() ? 1 : -1;
return 0;
}
pair<vi, int> div(vi a, int b) { //StatusOk
vi c(a.size());
int x = 0;
reverse(a.begin(), a.end());
for (int i = 0; i < (int)a.size(); ++i) {
c[i] = (x * 10 + a[i]) / b;
x = (x * 10 + a[i]) % b;
}
reverse(c.begin(), c.end());
while(c.size() > 1 and not c.back()) c.pop_back();
return {c, x};
}
pair<vi, vi> div(vi a, vi b) {
vi c, d;
while (cmp(a, b))
return {c, d};
}
vi get() {
string s;
cin >> s;
vi res(s.size());
for (int i = 0; i < sz(s); ++i)
res[i] = s[s.size() - i - 1] - '0';
return res;
}
void print(const vi& res) {
for (int i = res.size() - 1; ~i; --i)
cout << res[i];
}
int main() {
vi a = get();
int b;
cin >> b;
pair<vi, int> res = div(a, b);
print(res.first);
cout << '\n' << res.second;
}