import scala.io.StdIn.readLine
import scala.collection.mutable.ArrayBuffer

object Main {
  def isHamming(num:Int):Boolean = {
    var n = num
    while(n%2==0) n = n/2
    while(n%3==0) n = n/3
    while(n%5==0) n = n/5

    if(n==1) true
    else false
  }

  def main(args:Array[String]) = {
    var s = "0"
    val b = new ArrayBuffer[String]
    while({s=readLine.trim;s}!="0") {
      val n = s.split(" ").map(_.toInt)
      b+=(n(0) to n(1)).count(i=>isHamming(i)).toString
    }
    println(b.mkString("\n"))
  }
}