#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n;
  cin >> m;
  int x = n / m;
  int z = 0;
  int xx = 0;
  int zz;
  do {
    n = n + x;
    zz = z;
    z = n / m;
    xx = xx + x;
    x = z - xx;
  } while (zz != z && x != 0);
  cout << n;
}
