from __future__ import print_function import sys def to_int(x): bs = [] for b in x: if bs and bs[-1]: bs.append(0 if b == "1" else 1) else: bs.append(1 if b == "1" else 0) return int("".join(map(str, bs)), 2) n, a, b = sys.stdin.readline().split(); n = int(n) print(to_int(b) - to_int(a) - 1)