Let $\mathcal{A}$ be the set of finite sequences of positive integers $a_1,a_2,\dots,a_k$ such that $|a_n-a_{n-1}|=a_{n-2}$ for all $3\leqslant n\leqslant k$. If $a_1=a_2=1$, and $k=18$, determine the number of elements of $\mathcal{A}$.
1. **Define the sequence and initial conditions:**
   We are given a sequence \(a_1, a_2, \ldots, a_k\) with \(a_1 = a_2 = 1\) and \(k = 18\). The sequence must satisfy the condition \(|a_n - a_{n-1}| = a_{n-2}\) for all \(3 \leq n \leq k\).

2. **Analyze the sequence behavior:**
   - For \(n = 3\), we have \(|a_3 - a_2| = a_1\). Since \(a_1 = a_2 = 1\), this implies \(|a_3 - 1| = 1\). Therefore, \(a_3\) can be either 2 or 0. However, since \(a_3\) must be a positive integer, \(a_3 = 2\).
   - For \(n = 4\), we have \(|a_4 - a_3| = a_2\). Since \(a_3 = 2\) and \(a_2 = 1\), this implies \(|a_4 - 2| = 1\). Therefore, \(a_4\) can be either 3 or 1. 

3. **Pattern of the sequence:**
   - If \(a_4 = 3\), then \(a_5\) must satisfy \(|a_5 - 3| = 2\), so \(a_5\) can be either 5 or 1.
   - If \(a_4 = 1\), then \(a_5\) must satisfy \(|a_5 - 1| = 2\), so \(a_5\) can be either 3 or -1. Since \(a_5\) must be positive, \(a_5 = 3\).

4. **Generalize the pattern:**
   - Denote each term \(a_3\) and onward by \(>\) if it exceeds the previous term and \(<\) otherwise. For example, \(a_3 = 2\) is \(>\).
   - After a \(>\), the next term can be either \(>\) or \(<\). However, after a \(<\), the next term must be \(>\) because the sequence must remain positive.

5. **Count the valid sequences:**
   - We need to count the number of sequences of \(>\)'s and \(<\)'s such that no two \(<\)'s are adjacent.
   - This is equivalent to counting the number of ways to place \(<\)'s in a sequence of \(>\)'s such that no two \(<\)'s are adjacent.

6. **Use combinatorial arguments:**
   - Let \(m\) be the number of \(<\)'s in the sequence. The number of ways to place \(m\) \(<\)'s in a sequence of \(16\) \(>\)'s (since \(a_1\) and \(a_2\) are fixed) is given by \(\binom{16 - m + 1}{m}\).
   - Summing over all possible values of \(m\) from 0 to 8 (since \(k = 18\) and we start counting from \(a_3\)), we get:
     \[
     \sum_{m=0}^{8} \binom{16 - m + 1}{m} = \binom{16}{0} + \binom{15}{1} + \binom{14}{2} + \cdots + \binom{8}{8}
     \]

7. **Calculate the sum:**
   \[
   \binom{16}{0} + \binom{15}{1} + \binom{14}{2} + \binom{13}{3} + \binom{12}{4} + \binom{11}{5} + \binom{10}{6} + \binom{9}{7} + \binom{8}{8} = 1 + 15 + 91 + 286 + 495 + 462 + 210 + 36 + 1 = 1597
   \]

Conclusion:
\[
\boxed{1597}
\]