How long till Halley's Comet returns? Halley's Comet is the only comet that may appear (i.e. become visible to the naked eye on Earth) twice in a human lifetime. The orbital period of Halley's Comet is not constant: it has varied between 75 to 79 Earth years since the first definite apparition was recorded in 240 BCE. This variability is mainly driven by gravitational interactions between the comet and the planets of the Solar System. For the three millennia up to the year 3000, Halley's Comet appeared, or is projected to appear, in the following years:
66, 141, 218, 295, 374, 451, 530, 607, 684, 760, 837, 912, 989, 1066, 1145, 1222, 1301, 1378, 1456, 1531, 1607, 1682, 1758, 1835, 1910, 1986, 2061, 2134, 2209, 2284, 2358, 2430, 2504, 2579, 2653, 2726, 2795, 2863, 2931, 3000
Apparitions beyond 2134 predicted using this orbit simulator. The simulations account for gravitational perturbations due to the planets but not for other effects, such as changes in the comet's outgassing rate, that also affect its orbit. See here for further discussion.
Task
Write a program or function that takes as input a positive integer up to 3000 (inclusive), representing a year, and outputs/returns the number of years until the next apparition of Halley's Comet. In other words, if the input year is \$y\$ and Halley's Comet next appears in year \$y_\text{H}\ge y\$, find \$y_\text{H}-y\$. The shortest code (in bytes) in each language wins.
Test cases
   1 -&gt; 65
1066 -&gt;  0
1067 -&gt; 78
1986 -&gt;  0
1987 -&gt; 74 
2021 -&gt; 40
JavaScript (Node.js), 74 bytes

n=&gt;Buffer(&quot;BKMMOMOMMLMKMMOMOMNKLKLMKLKIKKJHJKJIEDDE&quot;).every(c=&gt;(n-=c)&gt;0)-n

Try it online!
Commented
n =&gt;              // n = input year
  Buffer(         // build a buffer consisting of
    &quot;BKMM...EDDE&quot; // the year deltas encoded as ASCII codes
  )               // 'B' -&gt; 66, + 'K' (75) -&gt; 141, etc.
  .every(c =&gt;     // for each value c in there:
    (n -= c)      //   subtract c from n
    &gt; 0           //   and go on while the result is positive
  )               // end of every(), which yields false
  - n             // return -n