#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n, m;
  cin >> n >> m;
  int day = 1;
  while (n) {
    n--;
    if (day % m == 0) n++;
    day++;
  }
  cout << day - 1;
}
int main() {
  int t = 1;
  while (t--) {
    solve();
    puts("");
  }
}
