405224: GYM101848 H Loop String

Memory Limit:512 MB Time Limit:4 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

H. Loop Stringtime limit per test4 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard output

There are two strings s, t, with length infinity. Their periods are n and m, respectively.

Period of a string, has the following definition: if s has a period of n, then s[1..n] = s[n + 1..2n] = s[dn + 1..(d + 1)n] for all d ≥ 0, in which s[i..j] is a substring of s starting from the i-th character and ends with the j-th character.

Now we want to know how many i (1 ≤ i ≤ k) satisfies si = ti. In other words, in how many positions s[1..k] and t[1..k] have the same character?

Input

The first line contains three space-separated integers n, m, k (1 ≤ n, m ≤ 125 512, 1 ≤ k ≤ 1018).

The second line contains a string with length n, which is one period of s.

The third line contains a string with length m, denoting t.

For some mysterious reasons, s and t both consist of only four upper-case letters: A, G, C and T.

Output

Output the answer.

ExamplesInput
5 4 9
AGCAG
AGCC
Output
5
Input
5 4 9
AAAAA
AAAA
Output
9

加入题单

算法标签: