[Question]
  [
You will be given two integers \$M\$ and \$N\$. Find the number of pairs \$(x,y)\$ such that \$1 \le x \le M\$, \$1 \le y \le N\$ and \$(x+y)\bmod5 = 0\$.
For example, if \$M = 6\$ and \$N = 12\$, pairs which satisfies such conditions are, \$(1,4), (4,1), (1,9), (2,3), (2,8), (3,2), (3,7), (3,12), (4,6), (6,4), (4,11), (5,5), (5,10), (6,9)\$
Total \$14\$.
### Sample
```
Input : 6 12
Output: 14
Input : 11 14
Output: 31
Input : 553 29
Output: 3208
Input : 2 2
Output: 0
Input : 752486 871672
Output: 131184195318 
```
This is a code-golf challenge so code with lowest bytes wins!
### Update
**[Jonathan Allan's](https://codegolf.stackexchange.com/a/205303/95294)** solution has the smallest code size, **5 bytes**. However, it doesn't produce an answer for the last given test.
I have decided to go with the next answer with the shortest size that produces the correct answer for the largest test, there is a tie between two golfers who competed neck-to-neck.
I proudly present the winners of this challenge **[Lyxal](https://codegolf.stackexchange.com/a/205326/95294)** and **[Kevin Cruijssen](https://codegolf.stackexchange.com/a/205374/95294)** with only **7 bytes** code! Congratulations! üéâ
As many of you, I found **[Arnauld's](https://codegolf.stackexchange.com/a/205311/95294)** answer most helpful in finding the correct solution. So, I am accepting Arnauld's answer.
Thank you, Golfers!
  
[Answer]
# [Python 2](https://docs.python.org/2/), 32 bytes
```
lambda m,n:(m*n+abs(m%5-~n%5))/5
```
[Try it online!](https://tio.run/##XY5NDoIwEIX3PcVsSFqpkVYKiOlN3BQFaUIHQiHCxqsjsCKuXubL@5luHuoW5VKN@NSNccXLgOOY@9FROoUzC5TWEVRtDxNYhN7gu6SCu1CwDc5HiCtkpNKP5dBE3QlDU3jqAnX@YqAYu6hly7pDNmI52VfwH4LxvuwH2D6kayHTutqVkE9tmxJEvl7aYjcOlN273uJq3h1LwoUkQnARE6WuXN6I5JKkSsZZwrNUJKn8AQ "Python 2 ‚Äì Try It Online")
Adapts an [idea from Arnauld](https://codegolf.stackexchange.com/a/205311/20260). We estimate that \$1/5\$ of the \$mn\$ pairs will satisfy the mod-5 condition. Th actual value may be one higher depending on the mod-5 values of \$m\$ and \$n\$, and we bump up \$mn\$ a bit so that these make it pass the next multiple of 5.
---
**34 bytes**
```
lambda m,n:m*n/5+(0<-m%5*(-n%5)<5)
```
[Try it online!](https://tio.run/##XY5NDoMgEIX3nIKNCSimQkWtlZt0Y1utJDIa1FRPT9GV6eplvryfGbe5G0C4doGX6mvzfNfYMCinxRCyRhsNpFIJbgeLV6wB2xo@DeHMRJzucDtD8JCiVj3cqcmEcJERSarYBDIkMQSSVpK6PW1O6YSW6NiBf4jraWrsjPcfia@kSrWHIvTtdN9gXvpLaRiXmdD7aDV48@FwGeMCcc54iqS8MnFDggmUS5EWGStynuXiBw "Python 2 ‚Äì Try It Online")
**34 bytes**
```
lambda m,n:m*n/5+(m*n%5+m%5+n%5)/9
```
[Try it online!](https://tio.run/##XY7NDoMgEITvPAWXJlBJFCr@NbxJL7SVSiKrQU316Sl6Mj1sJvtlZnbHbe4GEMEs8FK9ds@3xo5BMy2OkDXZ6EUqlWEzeLxiC9hr@LSEM5dwusPtDCFCiox6hFOTu0IqExLlIhMXJypN67Cn3Smd0QYdd@AfYj1NrZ/x/iOJlVQpcyhC3872LeZN3JSFcZkJvY/eQjQfjlAwLhDnjOdIyhsTNRJMoFKKvCpYVfKiFD8 "Python 2 ‚Äì Try It Online")
**36 bytes**
```
lambda m,n:m*n/5+((5-m%5)*(5-n%5)<5)
```
[Try it online!](https://tio.run/##XY5BDoMgFET3nIKNCShNhYpaW27SDW21ksjXoKZ6eoquTFeT/zIzf4Z1ansQvpnhpTptn2@NLYNqnC0hS7LSSCqV4qZ3eMEGsNPwqQlnNuF0g@sRQoAUNerhD002hrNMCJEnG0kaB4Wgd0n9lreHfEortH@Cf4j1ONZuwttKEkqpUs2uCH1b09WYV@FSBoZ5IvQ2OAPBvDt8zrhAnDOeISkvTFyRYAIVUmRlzsqC54X4AQ "Python 2 ‚Äì Try It Online")
**36 bytes**
```
lambda m,n:m*n/5+(abs(m%5+n%5*1j)>4)
```
[Try it online!](https://tio.run/##XY5NDoIwEIX3PUU3JK00kakUEFNP4qYoCIYOhEKE01dgRVy9zJf3M/0y1h1KX0341K2xxctQKzB3k2VsDhceKK0jWnUDnWmDdDD4LhkIGwLf4HKEuEJOKv3whyZ7wrMKmSkcs4EKMVAn@PB7zP2Wt4d8xHOyL@E/pMa5chjp9iVbS7nW1a6EfOumLSnk66Ub7KeR8Vs/NLiad4dPBEgCICAmSl2EvBIpJEmVjLNEZCkkqfwB "Python 2 ‚Äì Try It Online")
**36 bytes**
```
lambda m,n:m*n/5+(m%5*5/4+n%5*5/4>5)
```
[Try it online!](https://tio.run/##XY5BDoMgFET3nIJNE1AShYpaG3qSbmirlUS@BjXV01O0G9PV5L/MzJ9hndoehG9meKpO28dLY8ugGmdLyBKv9CSVSnHTO7xgA9hpeNeEMxtzusH1CCFAihp194cmG0EiY2JPMpJJFsNPb5L6LW8P@ZRWaP8E/xDrcazdhLeVJJRSpZpdEfq0pqsxr8KlDAzzROh1cAaCeXf4nHGBOGc8Q1KembggwQQqpMjKnJUFzwvxBQ "Python 2 ‚Äì Try It Online")
**36 bytes**
```
lambda m,n:m*n/5+(m%5+n%5+m*n%5/4>5)
```
[Try it online!](https://tio.run/##XY7BDoMgEETvfAUXE6gkChW1NvRLeqGtVBJZDWpav56iJ9PDZjMvM7M7rnM3gAhmgafqtXu8NHYMmmlxhHzTlSZSqRybweMvtoC9hndLOHMppxtcjxAipMioezg0uRNkMiUukSnEiTKRWXGTNGx5d8jntEH7JfiHWE9T62e8fUliKVXK7BuhT2f7FvMmKmVhXGZCr6O3EM27I5SMC8Q54wWS8szEBQkmUCVFUZesrnhZiR8 "Python 2 ‚Äì Try It Online")
[Answer]
# JavaScript (ES6), 29 bytes
Takes input as `(m)(n)`.
```
m=>g=n=>n&&(m+n%5)/5+g(n-1)|0
```
[Try it online!](https://tio.run/##XcyxCoMwEADQvV@RpXKH2OSiETvEfxGroUUvouLkv6dJtzo/eJ/u6LZ@fS97wf41hNGG2bbOsm05y2DO@W5QmtwBF4SnCr3nzU/DY/IORqgRSCMKIaQUVN3@lShylThqSRc1pkTQz8hJtWourqP@6uQqfAE "JavaScript (Node.js) ‚Äì Try It Online")
### How?
Let's consider a grid of width \$m\$ with 1-indexed coordinates and an `X` mark on each cell for which:
$$(x+y)\equiv 0\pmod 5$$
Here are the first few rows for \$m=9\$:
```
   | 1 2 3 4 5 6 7 8 9
---+-------------------
 1 | - - - X - - - - X
 2 | - - X - - - - X -
 3 | - X - - - - X - -
 4 | X - - - - X - - -
 5 | - - - - X - - - -
 6 | - - - X - - - - X
 7 | - - X - - - - X -
```
Computing \$m+(y\bmod5)\$ is equivalent to left-padding each row in such a way that all `X` marks are vertically aligned and appear on columns whose index is a multiple of \$5\$.
With such a configuration, the number of marks is directly given by \$\lfloor{L\_y/5}\rfloor\$, where \$L\_y\$ is the updated length of the \$y\$-th row.
```
 y | y%5 |         padded row         | length | // 5
---+-----+----------------------------+--------+------
 1 |  1  |  + - - - X - - - - X       |   10   |   2
 2 |  2  |  + + - - X - - - - X -     |   11   |   2
 3 |  3  |  + + + - X - - - - X - -   |   12   |   2
 4 |  4  |  + + + + X - - - - X - - - |   13   |   2
 5 |  0  |  - - - - X - - - -         |    9   |   1
 6 |  1  |  + - - - X - - - - X       |   10   |   2
 7 |  2  |  + + - - X - - - - X -     |   11   |   2
---+-----+----------^---------^-------+--------+------
         |  0 0 0 0 **0** 0 0 0 0 **1** 1 1 1 |
         |  1 2 3 4 **5** 6 7 8 9 **0** 1 2 3 |
```
We use this method to recursively compute the number of marks on each row.
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 5 [bytes](https://github.com/DennisMitchell/jelly/wiki/Code-page)
```
p¬ß5·∏çS
```
**[Try it online!](https://tio.run/##y0rNyan8/7/g0HLThzt6g////2/239AIAA "Jelly ‚Äì Try It Online")**
### How?
```
p¬ß5·∏çS - Link: positive integer, M; positive integer N
p     - (implicit [1..M]) Cartesian product (implicit [1..N])
 ¬ß    - sums
  5·∏ç  - five divides? (vectorises)
    S - sum
```
[Answer]
# [J](http://jsoftware.com/), 20 bytes
```
1#.[+/\0=5|1}.1+i.@+
```
[Try it online!](https://tio.run/##LczBCsIwEATQe79iUbBI6jazSZq0UCgKnsSD13oTi/XiD@i3x4T2MId5u8w7bricqO@opIo0dSkHptPtco7Y8qjqu@7dFz@GmnlQcV9cj0xjp@qhyhdRqt7NXBTPx@tDsNRTQxNBFjBIAGSxq4gOyZwzCaVdUCeR3NcZAwSL1hnkX@/EhrwaPBovFP8 "J ‚Äì Try It Online")
The standard `O(m*n)` cartesian product solution saves 3 bytes `[:+/@,0=5|2++/&i.`, but I figured I'd try a different approach:
A solution using a sliding window.
I *think* J is able to optimize this approach automatically into `O(m+n)`... in any case, I get an out of memory error on the final test case on TIO with the cartesian product approach but not with this one
Let's take `6 f 12` as an example:
1. Generate the numbers 1 through 18 `1+i.@+`:
```
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
```
2. Kill the first 1 `1}.`:
```
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
```
3. Turn it into a 0-1 list indicating which numbers are divisible by 5 `0=5|`
```
0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0
```
4. Create a sliding window of length of the left arg (either arg would work though), summing each piece of the window `[+/\`:
```
       1
  /`````````\ etc...
0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0
\_________/
      1
Final result: 1 1 1 2 1 1 1 1 2 1 1 1
```
5. Sum of all those numbers `1#.`:
```
14
```
[Answer]
# [Python 3](https://docs.python.org/3/), 50 bytes
```
lambda n,m:sum((i//n+i%n)%5==3for i in range(n*m))
```
[Try it online!](https://tio.run/##Hc1BCoMwEAXQfU4xG2HSipJYhQrepJsUtR1wJiFJF57eRmf5/@NP2PPXS3esMMHr2By/ZwdS85h@jEhtK3eqRFf9NHWrj0BAAtHJZ0G5sdYHcfAxQ9qTUifYSJbTlKBJeSYZFZSTGri8YBeQJNcXa1LYKKPWlwixFLjiKcvuAMYqY8A8VN93YJ/Kgv0D "Python 3 ‚Äì Try It Online")
[Answer]
# [APL (Dyalog Unicode)](https://www.dyalog.com/), 11 bytes
Full program.
```
‚â¢‚ç∏0=5|+/¬®‚ç≥‚éï
```
[Try it online!](https://tio.run/##SyzI0U2pTMzJT///qKO94P@jzkWPencY2JrWaOsfWvGod/Ojvqkgmf8KYFDAZaZgaMQF4xgaKhiawHmmpsYKRpZwrpECQqG5qZGJhZmChbmhmbkRAA "APL (Dyalog Unicode) ‚Äì Try It Online") (largest test case would work with 3TB RAM)
Reads quite literally as the problem specification:
`‚â¢` count `‚ç∏` where `0=` 0 equals `5|` the mod-5 of `+/` the sum of `¬®` each of `‚ç≥` all indices until `‚éï` the input.
[Answer]
# [MATL](https://github.com/lmendo/MATL), 9 bytes
```
:i:!+5\~z
```
[Try it online!](https://tio.run/##y00syfn/3yrTSlHbNKau6v9/My5DIwA "MATL ‚Äì Try It Online")
### How it works
```
:    % Implicit input: M. Range [1 2 ... M]
i:   % Input: N. Range [1 2 ... N]
!    % Transpose
+    % Add, element-wise with broadcast. Gives an N√óM matrix
5    % Push 5
\    % Modulus, element-wise
~    % Negate
z    % Number of nonzeros. Implicit display
```
[Answer]
# [Pyth](https://github.com/isaacg1/pyth), ~~12~~ 11 bytes
*-1 thanks to @Mukundan*
```
lf!%sT5*FSM
```
[Try it online!](https://tio.run/##K6gsyfj/PydNUbU4xFTLLdj3//9oU1NjHSPLWAA "Pyth ‚Äì Try It Online")
```
lf!%sT5*FSM
         SM    Map 1-indexed range to each input
       *F      Cartesian product of the two ranges
 f              Filter by:
    sT          - sum of elements..
  !%  5         - .. is divisible by 5
l               Take the length
```
[Answer]
# [R](https://www.r-project.org/), 40 bytes
```
function(m,n)sum(!(rep(1:m,e=n)+1:n)%%5)
```
[Try it online!](https://tio.run/##K/pfkJhZVBxfXJobn5JZZmr7P600L7kkMz9PI1cnTxMorKGoUZRaoGFolauTapunqW1olaepqmqqiaZRw0zH0EjzPwA "R ‚Äì Try It Online")
[Answer]
# [MathGolf](https://github.com/maxbergmark/mathgolf/blob/master/create_explanation.py), 7 [bytes](https://github.com/maxbergmark/mathgolf/blob/master/code_page.py)
```
‚ïí5%+5/Œ£
```
Port of [*@Arnauld*'s JavaScript answer](https://codegolf.stackexchange.com/a/205311/52210), so make sure to upvote him!
[Try it online.](https://tio.run/##y00syUjPz0n7///R1Emmqtqm@ucW//9vpmBoxGVoqGBowmVqaqxgZMllpGDEZW5qZGJhpmBhbmhmbgQA)
**Explanation:**
```
‚ïí        # Push a list in the range [1, (implicit) first input]
 5%      # Modulo-5 on each value in the list
   +     # Add the second (implicit) input to each
    5/   # Integer-divide each value by 5
      Œ£  # And sum the list
         # (after which the entire stack joined together is output implicitly as result)
```
[Answer]
# [Python 2](https://docs.python.org/2/), 36 bytes
```
f=lambda m,n:m and(m%5+n)/5+f(m-1,n)
```
[Try it online!](https://tio.run/##PY7BasMwDIbvfgpdBnGadpXTpGkghzE6KNsobL2NUdLUpWaxYxSXLk@fiZXtIpD06dPvh3DunBqN9R0F6Ic@AdJ9d6FGC@5mvQ6kmwv1pnOtsSZEOI/jXIo/6pe4bf5Hby@b181u/757eHxO4EPFsVolMMVPOZ6qtraHYw02caWF2h0je5dNnLzPJqfITjFxcryeTasBSwGBhpJRcAnob6@bABXY2kfGBQ5aX/fG@UuI5Kz3LSeQUjDXaB9gvX1aE3VUwoF0/SWA@JQ/sIshT2wAYkdV3cRjDqgAFwKRK6QosiwFtYJUzQuhQMFcLDO1KHIolpgvmU0RiwWushQL@AE "Python 2 ‚Äì Try It Online")
Use [@Arnauld's formula](https://codegolf.stackexchange.com/a/205311/92237), be sure to checkout and upvote his answer!
---
Original solution, using a longer formula:
# [Python 2](https://docs.python.org/2/), ~~42~~ 41 bytes
*-1 byte thanks to @xnor!*
```
f=lambda m,n:m and(n%5>~m%5)+n/5+f(m-1,n)
```
[Try it online!](https://tio.run/##PY5RS8MwEMff8ynuZdB03dylS9cWKohMGCqC7k1kdF3Ggk0a0pS5F796PRz6cnB3v/vd313CqbNi1MZ1PkB/6RPwqu8G3yhG3bxXwatm8L3ubKuNDhEu4jjj7I/6Ja6b/9Hr0@Z5s929be/uHxN4F3EsigRm@MHHY9XWZn@owSS2NFDbQ2Qn8vbbTCSf2hs5PUZmhonl4/mkWwVYMgj@UhIPNgH15VQToAJTu0jbQGnr805bN4SIz3vXUgzOGXGNcgHWLw9r7ztfwt6r@pOBp1P6QC6CnCcDeHJU1VU8ZoACcMkQqUKKTMoURAGpWORMgIAFW0mxzDPIV5itiE0R8yUWMsUcfgA "Python 2 ‚Äì Try It Online")
For each number `i` between 1 to `m`, there are `(n%5+i%5>4)+n/5` numbers between 1 to n that can be paired with `i`.
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), ~~9~~ ~~8~~ 7 bytes
```
L5%+5√∑O
```
[Try it online!](https://tio.run/##yy9OTMpM/f/fx1RV2/Twdv///w2NuMwA "05AB1E ‚Äì Try It Online")
A 100% port of @Arnauld's Javascript answer
[Answer]
# [K (ngn/k)](https://bitbucket.org/ngn/k), 15 bytes
```
+//~5!+/:/1+!:'
```
[Try it online!](https://tio.run/##y9bNS8/7/z/NSltfv85UUVvfSt9QW9FK/X@agpmCoRFXmoKhoYKhCZA2NTVWMLIEMowUDLj@AwA "K (ngn/k) ‚Äì Try It Online")
[Answer]
# [Wolfram Language (Mathematica)](https://www.wolfram.com/wolframscript/), 56 bytes
```
Length@Solve[1<=x<=#&&1<=y<=#2&&Mod[x+y,5]==0,Integers]&
```
[Try it online!](https://tio.run/##y00syUjNTSzJTE78n2773yc1L70kwyE4P6csNdrQxrbCxlZZTQ3IqAQyjNTUfPNToiu0K3VMY21tDXQ880pS01OLimPV/gcUZeaV6DukOzg4KFRXm@kYGtXqVBsa6hiaAGlTU2MdI0sgw0jHqLb2/38A "Wolfram Language (Mathematica) ‚Äì Try It Online")
[Answer]
# perl -M5.010 -al, 49 bytes
```
for(1..$_){for$y(1..$F[1]){($_+$y)%5||$c++}}say$c
```
[Try it online!](https://tio.run/##K0gtyjH9r5Jsa2D9Py2/SMNQT08lXrMayFSpBHPcog1jNas1VOK1VSo1VU1ralSStbVra4sTK1WS//83UzA04jI0VDA04TI1NVYwsuQyUjD6l19QkpmfV/xf19dUz8DQ4L9uYg4A "Perl 5 ‚Äì Try It Online")
This is a pretty stupid, "iterate over all pairs, count the ones where sum mod 5 equals zero", solution. There's a nicer formula, but I couldn't (yet) reduce that down enough. It will take a very long time to calculate the answer to (752486, 871672), but there was no time limit stated.
The TIO link has a `$c = 0;` in the header. This isn't needed for a single line solution; it's only there to make it work with multiple inputs (and as such, TIO won't count those bytes).
[Answer]
# [Japt](https://github.com/ETHproductions/japt), ~~11~~ 10 [bytes](https://en.wikipedia.org/wiki/ISO/IEC_8859-1)
```
√µ √Ø+V√µ)√®v5
```
[Try it](https://petershaggynoble.github.io/Japt-Interpreter/?v=1.4.6&code=9SDvK1b1Keh2NQ&input=MTEKMTQ)
```
√µ √Ø+V√µ)√®v5     :Implicit input of integers U & V
√µ              :Range [1,U]
  √Ø            :Cartesian product with
    V√µ         :  Range [1,V]
   +           :  Reduce each pair by addition
      )        :End Cartesian product
       √®       :Count the elements
        v5     :  Divisible by 5
```
[Answer]
# [C (gcc)](https://gcc.gnu.org/), 36 bytes
```
f(n,m){n=m*n/5+((5-m%5)*(5-n%5)<5);}
```
[Try it online!](https://tio.run/##hZDdaoQwEIXv9ykGQTAa0ajxB9felD7FKmXr6jYXxsV4IRWf3Y67alsobSAZBs75ODmlfS3Lea4NSRsyyqwxpcMtw@B2o3Ni4pQ4j5yk09ychTQIjAfAI2QP8rWvVK9OBWQAY0iBMQqc@xS8KQXHpBBxL4hDXPq2hTdxhbrtFqsC09kxzQ8M85ATICL5wsQRCyPvH0w13Kqyv1PGBeBjGN9zYwruimE@Y3HAEu6z@A9Y@X7uTOgeJC0fXrx8SJ7xco3C993XpvTuWAjGkkGgxU1xHEGJj6rFXh@fI866o4qkYFliK3KLr9C6y0@ioHsvoiDpLr11KK4NTb9Q0C9gPy2vrnKJ2X43U1AUf7PWI4osUxtwOkzzJw "C (gcc) ‚Äì Try It Online")
A port of one of [xnor](https://codegolf.stackexchange.com/users/20260/xnor)'s [formulas](https://codegolf.stackexchange.com/a/205302/9481).
[Answer]
# [Erlang (escript)](http://erlang.org/doc/man/escript.html), 69 bytes
Posting before I run out of time.
```
f(X,Y)->[[A,B]||A<-lists:seq(1,X),B<-lists:seq(1,Y),((A+B)rem 5)==0].
```
[Try it online!](https://tio.run/##Vci9CoMwEADg3afIeIcXqUI7SBWSp1BCBpGzHPjTJoEuvnva1W/8OKzT/tIc5yDvlIu8wEAj6t45Q9afp3nqVWKKbeQP1DQg2euMSACmtBh4U3fsupuv8jbJDs6j0n2h/uRov0ESwwIPUnWDWOUf "Erlang (escript) ‚Äì Try It Online")
[Answer]
# [Charcoal](https://github.com/somebody1234/Charcoal), ~~16~~ 12 bytes
```
Ôº©Œ£√∑‚Å∫Ôπ™‚Ä¶¬∑¬πÔºÆ‚ÅµÔºÆ‚Åµ
```
[Try it online!](https://tio.run/##bcixDYAgEEDRVSiPRAtMtLHUhkJjdAJEoiQIBjnWPxnA3/2nLxV1UI5oidYnGNSbYMMbpE@jzfYwsDh8YQoHulBUl7PZrMqfBkTFpH8wzXjvJgLnFWv5n5V6oo6JhursPg "Charcoal ‚Äì Try It Online") Link is to verbose version of code. Port of @KevinCruijssen's answer, although that's apparently a port of @Arnauld's answer. Explanation:
```
     ‚Ä¶¬∑        Inclusive range from
       ¬π        Literal `1` to
        ÔºÆ       First input number
    Ôπ™           Vectorised Modulo
         ‚Åµ      Literal `5`
   ‚Å∫            Vectorised Plus
          ÔºÆ     Second input number
  √∑             Vectorised Integer divide by
           ‚Åµ    Literal `5`
 Œ£              Take the sum
Ôº©               Cast to string
                Implicitly print
```
Previous 16-byte brute force answer:
```
ÔºÆŒ∏Ôº©‚Ññ‚≠ÜÔºÆ‚≠ÜŒ∏Ôπ™‚Å∫¬≤‚Å∫ŒπŒª‚Åµ0
```
[Try it online!](https://tio.run/##S85ILErOT8z5/98zr6C0xK80Nym1SKNQ05oroCgzr0TDObEYSOSXApnBJUCRdN/EAg1kpZo6CgiJQh0F3/yU0px8jYCc0mINIx0FMJ2po5CjCVRoqgkilQyUgLT1//9mCoZG/3XLcgA "Charcoal ‚Äì Try It Online") Link is to verbose version of code. Explanation:
```
ÔºÆŒ∏
```
Input `M`.
```
‚≠ÜÔºÆ‚≠ÜŒ∏
```
Input `N` and loop over `N` and `M`, casting the result to a string.
```
Ôπ™‚Å∫¬≤‚Å∫ŒπŒª‚Åµ
```
Take the sum modulo 5, adjusted for 1-indexing (sigh).
```
Ôº©‚Ññ...0
```
Count the `0`s in the result.
[Answer]
# [Vyxal](https://github.com/Lyxal/Vyxal) `s`, 6 bytes
```
…æ5%+5·∏≠
```
[Try it Online!](https://lyxal.pythonanywhere.com?flags=s&code=%C9%BE5%25%2B5%E1%B8%AD&inputs=553%0A29&header=&footer=)
]