#include <bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/STACK:256000000")
template <class T>
T sqr(T a) {
  return a * a;
}
vector<vector<pair<int, int> > > gr;
int n, m;
int was[300000];
void init() {
  cin >> n >> m;
  int k = 0;
  while (n) {
    n--;
    k++;
    if (k % m == 0) {
      n++;
    }
  }
  cout << k;
}
void solve() {}
int main() {
  init();
  solve();
  return 0;
}
