function sort(x) {
  args = x;
  continue2 = true;
  while (continue2) {
    continue2 = false;
    var j_end = args.length - 1;
    var j_inc = 1;
    if (1 > j_end) {
      j_inc = -j_inc;
    }
    for (j = 1; j_inc >= 0 ? j <= j_end : j >= j_end; j += j_inc) {
      cur = args[(j - 1)];
      next = args[((j + 1) - 1)];
      if (next < cur) {
        args[(j - 1)] = next;
        args[((j + 1) - 1)] = cur;
        if (j < args.length - 1) {
          continue2 = true;
        }
      }
    }
  }
  return args;
}

function main(input) {
  sorted = sort(input.split(' '));
  result = 0;
  var i_end = sorted.length - 1;
  var i_inc = 1;
  if (1 > i_end) {
    i_inc = -i_inc;
  }
  for (i = 1; i_inc >= 0 ? i <= i_end : i >= i_end; i += i_inc) {
    cur = sorted[(i - 1)];
    next = sorted[((i + 1) - 1)];
    result = result + Math.abs(cur - next);
  }
  console.log(result);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));