'use strict'

class Main {
  check(n) {
    const ret = [];
    n[1] = (n[1] == null ? 0 : n[1]);
    ret[0] = (n[0] == n[1]) ? 0 : 1;
    for (let i = 1; i< n.length; ++i) {
      const dig = ((n[i] == 1) && (n[0] == 0)) ? 1 : 0;
      ret.push(dig);
    } 
    return ret;
  }

  solve() {
    const nums = input.nextIntArr();
    --nums[0];
    const a = Array.from(nums[0].toString(2)).reverse()
    .map(e => parseInt(e));
    const b = Array.from(nums[1].toString(2)).reverse()
    .map(e => parseInt(e));
    const ret = [];
    for(let i = 0; i < Math.max(a.length, b.length); ++i) {
      a[i] = (a[i] == null ? 0 : a[i]);
      b[i] = (b[i] == null ? 0 : b[i]);
    }
    const dig_a = this.check(a);
    const dig_b = this.check(b);
    for (let i = 0; i < dig_a.length; ++i) {
      ret.push(dig_a[i] == dig_b[i] ? 0 : 1);
    }
    
    console.log(parseInt(ret.reverse().join(''),2));
  }
}

class Input {
  constructor() {
	this.cursor = 0;
	this.inputAll();
  }

  inputAll() {
	this.data = (require("fs").readFileSync("/dev/stdin", "utf8")).split('\n');
	return this.data;
  }

  nextLine(n) {
	if (n) {
	  const ret = this.data.slice(this.cursor, this.cursor + n);
	  this.cursor += n;
	  return ret;
	}
	return this.data[this.cursor++];
  }

  nextStrArr() {
	return this.nextLine().split(' ');
  }

  nextIntArr() {
	return this.nextStrArr().map((e) => parseInt(e));
  }

  nextFloatArr() {
	return this.nextStrArr().map((e) => parseFloat(e));
  }

  nextIntLine(n) {
	return this.nextLine(n).map((e) => parseInt(e))
  }

  nextFloatLine(n) {
	return this.nextLine(n).map((e) => parseFloat(e))
  }

  nextStrRange(n) {
	return this.nextLine(n).map((line) => line.split(' '));
  }

  nextIntRange(n) {
	return this.nextLine(n).map((line) => line.split(' ').map((e) => parseInt(e)));
  }

  nextFloatRange(n) {
	return this.nextLine(n).map((line) => line.split(' ').map((e) => parseFloat(e)));
  }
}

const input = new Input();
(new Main()).solve();
