#include <bits/stdc++.h>
using namespace std;
int arr[10005];
int main() {
  int n, m, sum = 0, var = 0;
  cin >> n >> m;
  int d = n - m;
  var = d;
  if (d < 0) d -= 2 * d;
  if (d == 0) {
    cout << "0" << endl;
    return 0;
  } else if (d == 1 | d == 2) {
    cout << "1" << endl;
    return 0;
  }
  d = d / 2;
  for (int i = 1; i <= d; i++) {
    sum += i;
  }
  d = var - d;
  for (int i = 1; i <= var; i++) {
    sum += i;
  }
  cout << sum << endl;
}
