{"raw_statement":[{"iden":"problem statement","content":"For a string $X$ of length $n$, let $f(X,k)$ denote the string obtained by repeating $k$ times the string $X$, and $g(X,k)$ denote the string obtained by repeating $k$ times the first character, the second character, $\\dots$, the $n$\\-th character of $X$, in this order. For example, if $X=$ `abc`, then $f(X,2)=$ `abcabc`, and $g(X,3)=$ `aaabbbccc`. Also, for any string $X$, both $f(X,0)$ and $g(X,0)$ are empty strings.\nYou are given a positive integer $N$ and strings $S$ and $T$. Find the largest non-negative integer $k$ such that $g(T,k)$ is a (not necessarily contiguous) subsequence of $f(S,N)$. Note that $g(T,0)$ is always a subsequence of $f(S,N)$ by definition.\nWhat is a subsequence? A (not necessarily contiguous) subsequence of a string $X$ is a string obtained by removing zero or more characters from $X$ and then concatenating the remaining elements without changing the order. For example, `ac`, `atcoder`, and (empty string) are all subsequences of `atcoder`, but `ta` is not."},{"iden":"constraints","content":"*   $N$ is an integer.\n*   $1\\leq N\\leq 10^{12}$\n*   $S$ and $T$ are strings consisting of lowercase English letters with lengths between $1$ and $10^5$, inclusive."},{"iden":"input","content":"The input is given from Standard Input in the following format:\n\n$N$\n$S$\n$T$"},{"iden":"sample input 1","content":"3\nabc\nab"},{"iden":"sample output 1","content":"2\n\nWe have $f(S,3)=$ `abcabcabc`. $g(T,2)=$ `aabb` is a subsequence of $f(S,3)$, but $g(T,3)=$ `aaabbb` is not, so print $2$."},{"iden":"sample input 2","content":"3\nabc\narc"},{"iden":"sample output 2","content":"0"},{"iden":"sample input 3","content":"1000000000000\nkzazkakxkk\nazakxk"},{"iden":"sample output 3","content":"344827586207"}],"translated_statement":null,"sample_group":[],"show_order":["default"],"formal_statement":null,"simple_statement":null,"has_page_source":true}