function Main(input) {
  var inputs = input.split(" ");
  var headnum = parseInt(inputs[1][0], 10);
  var a = parseInt(inputs[0], 10);
  var b = parseInt(inputs[1], 10);
  var cnt = 0;
  for (var i = 1; i <= headnum; i++) {
    for (var j = 0; j <= 9; j++) {
      for (var k = 0; k <= 9; k++) {
        var pn = i * 10000 + j * 1000 + k * 100 + j * 10 + i;
        if (pn >= a && pn <= b) cnt++;
      }
    }
  }
  console.log(cnt);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));