#include <bits/stdc++.h>
using namespace std;
int socks, day;
int main() {
  cin.sync_with_stdio(0);
  cin >> socks >> day;
  int i = 0;
  while (socks) {
    i++;
    if (!(i % day)) socks++;
    socks--;
  }
  cout << i;
}
