A positive integer $N$ is written on a board. In a step, the last digit $c$ of the number on the board is erased, and after this, the remaining number $m$ is erased and replaced with $|m-3c|$ (for example, if the number $1204$ is on the board, after one step, we will replace it with $120 - 3 \cdot 4 = 108$).
We repeat this until the number on the board has only one digit. Find all positive integers $N$ such that after a finite number of steps, the remaining one-digit number is $0$.
1. **Initial Setup and Observation:**
   - We start with a positive integer \( N \).
   - In each step, the last digit \( c \) of the number is erased, and the remaining number \( m \) is replaced with \( |m - 3c| \).
   - We need to find all \( N \) such that after a finite number of steps, the remaining one-digit number is \( 0 \).

2. **Formulation of the Problem:**
   - Let \( a_i \) be the number generated after the \( i \)-th operation, with \( a_0 = N \).
   - If \( a_i = 10m + c \), then \( a_{i+1} = |m - 3c| \).

3. **Modular Arithmetic Analysis:**
   - If \( |m - 3c| = m - 3c \), then:
     \[
     a_i \equiv 10(m - 3c) + 31c \equiv 10a_{i+1} \pmod{31}
     \]
   - If \( |m - 3c| = 3c - m \), then:
     \[
     a_i \equiv -10(3c - m) + 31c \equiv -10a_{i+1} \pmod{31}
     \]

4. **Induction Proof:**
   - **Base Case:** For \( i = q \), we have \( |m - 3c| = 0 \), so \( m = 3c \). Thus:
     \[
     a_q = 10m + c = 10 \cdot 3c + c = 31c \equiv 0 \pmod{31}
     \]
   - **Induction Hypothesis:** Assume \( a_i \equiv 0 \pmod{31} \) for some \( i \in \{1, 2, \ldots, n\} \).
   - **Inductive Step:** We need to show \( a_{i-1} \equiv 0 \pmod{31} \). Given:
     \[
     a_{i-1} \equiv \pm 10a_i \pmod{31}
     \]
     Since \( a_i \equiv 0 \pmod{31} \), it follows that:
     \[
     a_{i-1} \equiv 0 \pmod{31}
     \]
   - By induction, \( a_i \equiv 0 \pmod{31} \) for all \( i \).

5. **Conclusion from Induction:**
   - Since \( a_i \equiv 0 \pmod{31} \) for all \( i \), it follows that \( 31 \mid N \).

6. **Verification for Multiples of 31:**
   - **Lemma:** \( a_i < a_{i-1} \) for \( i \in \{1, 2, 3, \ldots, q\} \).
   - **Proof of Lemma:**
     - Let \( d \) be the last digit of \( a_{i-1} \) and \( n \) such that \( a_{i-1} = 10n + d \).
     - Then \( a_i = |n - 3d| \geq 0 \).
     - Since \( 31 \mid a_{i-1} \), \( a_{i-1} \geq 31 \).
     - If \( |n - 3d| = n - 3d \):
       \[
       a_i = n - 3d \quad \text{and} \quad a_i < a_{i-1} \iff n - 3d < 10n + d \iff 0 < 9n + 4d
       \]
       Since \( d \geq 0 \) and \( n \geq 3 \), this is true.
     - If \( |n - 3d| = 3d - n \):
       \[
       a_i < a_{i-1} \iff 3d - n < 10n + d \iff 2d < 11n
       \]
       Since \( d < 10 \) and \( n \geq 3 \), \( 2d < 20 \) and \( 11n \geq 33 \), so \( 2d < 11n \).

7. **Final Conclusion:**
   - Since \( a_i < a_{i-1} \) and \( a_j \equiv 0 \pmod{31} \), the sequence \( a_i \) is decreasing and must eventually reach \( 0 \).
   - Therefore, all multiples of \( 31 \) are solutions.

The final answer is \( \boxed{ N } \) such that \( 31 \mid N \).