#include <bits/stdc++.h>
using namespace std;
void showstack(stack<int> s) {
  while (!s.empty()) {
    cout << '\t' << s.top();
    s.pop();
  }
  cout << '\n';
}
int sumOfArray(int a[], int n) {
  int sum = 0;
  for (int i = 0; i < n; i++) {
    sum += a[i];
  }
  return sum;
}
void swap(int &a, int &b) {
  int temp = a;
  a = b;
  b = temp;
}
int binarySearchForIntegers(int arr[], int l, int r, int x) {
  if (r >= l) {
    int mid = l + (r - l) / 2;
    if (arr[mid] == x) return mid;
    if (arr[mid] > x) return binarySearchForIntegers(arr, l, mid - 1, x);
    return binarySearchForIntegers(arr, mid + 1, r, x);
  }
  return -1;
}
int binarySearchForStrings(string arr[], string x, int n) {
  int l = 0;
  int r = n - 1;
  while (l <= r) {
    int m = l + (r - l) / 2;
    int res;
    if (x == (arr[m])) res = 0;
    if (res == 0) return m;
    if (x > (arr[m]))
      l = m + 1;
    else
      r = m - 1;
  }
  return -1;
}
string convertToString(char *a, int size) {
  int i;
  string s = "";
  for (i = 0; i < size; i++) {
    s = s + a[i];
  }
  return s;
}
int main() {
  cout << fixed << setprecision(0);
  int n, m;
  cin >> n >> m;
  int sum = n, c = 0, i = 1;
  while (sum > 0) {
    if (i % m == 0) {
      sum++;
    }
    sum--;
    c++;
    i++;
  }
  cout << c << endl;
  return 0;
}
