#JavaScript (ES7), 133 bytes _**Edit**: Fixed to match the results returned by [Jonathan Allan's code][1], which was given as a reference implementation by the OP._ ---------- <!-- language: lang-javascript --> n=>[...Array(m=k=7**n)].reduce(s=>s+/^1*5?4{0,3}3?2{0,3}6?0{0,3}$/.test((--k+m).toString(7).replace(/0[62]|2[34]|4[51]/g,s=>s[1])),0) [Try it online!](https://tio.run/##HczNisIwGIXhvVfxLYTJ1zTprzowkxavwWWIUGpaHGsiSUYQ9dprdHOezeH9666d793xEpixBz0PYjaikZzzrXPdjZzFSWySxKDiTh/@e028aDzN9kWyaut7nlbPqi0/rtv84zLjQftACGMnekYe7C64oxnJBmPjMnUxkuVyXapHKataPWq5KlQ2pu@yLBRimuM8WEcMCCh@wMAvfEcoRbgvAHprvJ00n@wYLxS@gLEmLoWBGMTFc34B "JavaScript (Node.js) – Try It Online") ###How? We generate all numbers of \$N\$ digits in base 7 with an extra leading \$1\$ and interpret each digit as a Roman numeral symbol according to the following table: 0: I 4: C 1: M 5: D 2: X 6: V 3: L We replace all valid subtractive pairs of the form `AB` with `B`: <!-- language: lang-javascript --> s.replace(/0[62]|2[34]|4[51]/g, s => s[1])) // in the code s.replace(/I[VX]|X[LC]|C[DM]/g, s => s[1])) // with Roman symbols **Examples:** - `XLIXIV` becomes `LXV` - `XIIV` becomes `XIV`, leaving a `I` that will make the next test fail - `IC` is left unchanged, which also leaves an invalid `I` in place We check that the remaining symbols are in the correct order and do not appear more times than they're allowed to: <!-- language: lang-javascript --> /^1*5?4{0,3}3?2{0,3}6?0{0,3}$/.test(...) // in the code /^M*D?C{0,3}L?X{0,3}V?I{0,3}$/.test(...) // with Roman symbols [1]: https://tio.run/##jVPRatswFH2evuIuUCxjJ@BubGBwH5a0EEgIZJkJtHlQbKXVsCUjy6PZz6eSrLieS5vpQfjK59x77rlSdVRPgl@fTgcpSmCKSiVEUQMrKyEVVFLkTaYQyukBJNXf9FdVUTklNV2LknCs6LPyYwR6HYQExnP6HAImIex9HQHlTUklURT/ZZVFh2D2@yje@Y5oFjsACfaGgb156oXgzbdm3y7sPjX7dGb3pdfjmSWpaiRv08ZWwQ6CNrRREJn4XfkOdK0FoUE61Hb@hxQs1z2837uRz4/2ZJKJhiuc@XADkTUlM22NZot05IMOuVBAigK3x/N0u5jOlqNXZC9tT84dKWrq9JlG8o2GQfLBVCy4tb@Y85xljNaacN@VnNjGjdKudi/37tzYWS@BmwT2FmvGa@BmpoMK4bDkedKf3jTiTBvi2Q4@J/BN/8uhoBzXVL3FxCz4qtNCkjiTmZVP@CPFhjQg@DCGL/7HrtqDjWyom7p5DamZ/MBcnf5RPfUuvatVGwXuxeDO5FBnrihRyT80s1Q7QM@b/BasU1z7/Tdx@ead15HRIneX9m69WoawWensUQjfETIq2/qvLnWgACKXq5KMKwcMoW5K3HprlWriBUd8hNLb9Y/Vz1td2BqpO3An/QLeAx@Pxw/c6xz8D209@lUde3DlSMOf4Oy8qHXA89Dp9AI