Common Substrings
时间限制:C/C++/Rust/Pascal 5秒,其他语言10秒
空间限制:C/C++/Rust/Pascal 64 M,其他语言128 M
64bit IO Format: %lld

题目描述

A substring of a string T is defined as:

T( i, k)= TiTi +1... Ti+k -1, 1≤ ii+k-1≤| T|.

Given two strings A, B and one integer K, we define S, a set of triples (i, j, k):

S = {( i, j, k) | kK, A( i, k)= B( j, k)}.

You are to give the value of |S| for specific A, B and K.

输入描述:

The input file contains several blocks of data. For each block, the first line contains one integer K, followed by two lines containing strings A and B, respectively. The input file is ended by K=0.

1 ≤ |A|, |B| ≤ 105
1 ≤ Kmin{|A|, |B|}
Characters of A and B are all Latin letters.

输出描述:

For each case, output an integer |S|.

示例1

输入

复制
2
aababaa
abaabaa
1
xx
xx
0

输出

复制
22
5