B1. The digit sum of a number is obtained by adding the digits of the number. The digit sum of 1303, for example, is $1+3+0+3=7$.

Find the smallest positive integer $n$ for which the digit sum of $n$ and the digit sum of $n+1$ are both divisible by 5.
B1. 49999 We denote the digit sum of a number $n$ as $S(n)$. We are looking for the smallest positive integer $n$ that meets the following requirement:

- $S(n)$ and $S(n+1)$ are both divisible by 5.

The last digit of $n$ must be a 9. If this were not the case, then $S(n+1)$ would be equal to $S(n)+1$, because the last digit of $n+1$ is one greater than that of $n$ and the other digits are the same. However, $S(n)$ and $S(n)+1$ cannot both be divisible by 5, because then the difference $S(n+1)-S(n)=1$ would also be divisible by 5.

Therefore, the number $n$ must end in one or more 9s, say $k$ 9s. When we add 1 to $n$, those $k$ 9s each become the digit 0, and the digit before them is increased by 1 (if $n$ consists only of 9s, then $n+1$ consists of the digit 1 followed by $k$ zeros). Thus, $S(n+1)=S(n)-9 \cdot k+1$. Since $S(n+1)$ and $S(n)$ are both divisible by 5, the difference $S(n)-S(n+1)=9k-1$ is also divisible by 5. The smallest $k$ for which $9k-1$ is divisible by 5 is $k=4$.

Since $S(9999)=36$ is not divisible by 5, we then try the five-digit numbers that end in four 9s. The first digit of $n$ we call $a$ (so $n$ is written as a9999). The digit sum $S(n)=a+4 \cdot 9=a+36$ must be divisible by 5. The smallest $a$ for which this is true is $a=4$. Since $S(49999)=40$ and $S(50000)$ are both divisible by 5, $n=49999$ indeed meets the requirement. This is therefore the smallest number that meets the requirement.