{
TASK:rprimes
LANG:PASCAL
}

Program rprimes;
  var a,b,i:longint;
      br:integer;
      Mas:array[1..10000] of longint;
begin
  readln(a,b);
    br:=0;
    i:=a;
    for i:=a to b do
     begin
    if i mod 2 <> 0 then
      if i mod 5 <> 0 then
      if i mod 3 <> 0 then
      if i mod 7 <> 0 then
      if i mod 11 <> 0 then
      if i mod 17 <> 0 then
      if i mod 23 <> 0 then
        if (((i div 10) mod 2) <> 0) xor (i<10) then
        if (((i div 100) mod 2) <> 0) xor (i<100) then
        if (((i div 1000) mod 2) <> 0) xor (i<1000) then
        if (((i div 10000) mod 2) <> 0) xor (i<10000) then
        if (((i div 10) mod 3) <> 0) xor (i<10) then
          if (((i div 100) mod 3) <> 0) xor (i<100) then
          if (((i div 1000) mod 3) <> 0) xor (i<1000) then
          if (((i div 10000) mod 3) <> 0) xor (i<10000) then
          if (((i div 10) mod 7) <> 0) xor (i<10) then
          if (((i div 100) mod 7) <> 0) xor (i<100) then
          if (((i div 1000) mod 7) <> 0) xor (i<1000) then
          if (((i div 10000) mod 7) <> 0) xor (i<10000) then
               if (((i div 10) mod 11) <> 0) xor (i<10) then
          if (((i div 100) mod 11) <> 0) xor (i<100) then
          if (((i div 1000) mod 11) <> 0) xor (i<1000) then
          if (((i div 10000) mod 11) <> 0) xor (i<10000) then
               if (((i div 10) mod 13) <> 0) xor (i<10) then
          if (((i div 100) mod 13) <> 0) xor (i<100) then
          if (((i div 1000) mod 13) <> 0) xor (i<1000) then
          if (((i div 10000) mod 13) <> 0) xor (i<10000) then
               if (((i div 10) mod 17) <> 0) xor (i<10) then
          if (((i div 100) mod 17) <> 0) xor (i<100) then
          if (((i div 1000) mod 17) <> 0) xor (i<1000) then
          if (((i div 10000) mod 17) <> 0) xor (i<10000) then
               if (((i div 10) mod 23) <> 0) xor (i<10) then
          if (((i div 100) mod 23) <> 0) xor (i<100) then
          if (((i div 1000) mod 23) <> 0) xor (i<1000) then
          if (((i div 10000) mod 23) <> 0) xor (i<10000) then






  inc(br);
      end;

      writeln(br);


      end.
