#include <bits/stdc++.h>
using namespace std;
inline void reads(string& x) {
  char kk[((int)1e6 + 123)];
  scanf("%s", kk);
  x = kk;
}
int n, m, ans;
void solve() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    if (i % m == 0) n++;
  }
  printf("%d\n", n);
}
int main() {
  ios_base::sync_with_stdio(0);
  int t = 1;
  for (int caso = 1; caso <= t; caso++) {
    solve();
  }
}
