"use strict";

async function main(input) {
  input = input.trim().split(" ");
  let A = Number(input[0]);
  let B = Number(input[1]);
  while (true) {
    if (A == B) break;
    if (A > B) {
      B = B + Number(input[1]);
    } else {
      A = A + Number(input[0]);
    }
  }
  console.log(A);
}

main(require("fs").readFileSync("/dev/stdin", "utf-8"));
