prepend,append-Sequence Task

The prepend,append-Sequence is defined recursively, like this


a(1) = 1
a(n) = a(n-1).n  , if n is even
a(n) = n.a(n-1)  , if n is odd


where the . represents an integer concatenation.

So the first few terms are: 1,12,312,3124,53124,531246,7531246,... This is A053064.

Your task is, given an integer a > 0 to return n, such that the nth element in the prepend,append-Sequence is equal to a and if no such n exists return 0, a negative number or error out etc.

Rules


Input can be taken as an integer, string, list of characters/digits etc.
Output can be printed to STDOUT or returned (integer, string etc. is fine)
On invalid input &amp; in the case no such n exists your program may do anything but return a positive integer (eg. loop forever, return 0 etc.)
You may choose to use 0-indexing, but then the output in case no n exists cannot be 0


Test cases

1 -&gt; 1
12 -&gt; 2
21 -&gt; 0
123 -&gt; 0
312 -&gt; 3
213 -&gt; 0
211917151311975312468101214161820 -&gt; 21
2119171513119753102468101214161820 -&gt; 0
333129272523211917151311975312468101214161820222426283031 -&gt; 0
999795939189878583817977757371696765636159575553514947454341393735333129272523211917151311975312468101214161820222426283032343638404244464850525456586062646668707274767880828486889092949698100 -&gt; 100
C# (.NET Core), 83, 80, 60 59 bytes



n=&gt;{int i=0;for(var t="";t!=n;)t=++i%2&lt;1?t+i:i+t;return i;}


Try it online!

Takes the input as a string into a lambda function. 1-indexed. Returns the index of the value for truthy, or infitnitely loops for a "falsey"