package javaapplication1;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Bugs {
int[] stack = new int[2000000];
while ((line = reader.readLine()) != null) {
String[] split
= line.
split(" ");
int n
= Integer.
parseInt(split
[0]); char[] bug = split[1].toCharArray();
int idx = -1;
int state = 0;
int c;
while (n > 0 && (c = reader.read()) != -1) {
if (c == '\n') {
n--;
}
if (bug[state] == c) {
state++;
if (state == bug.length) {
if (idx >= 0) {
state = stack[idx--];
} else {
state = 0;
}
}
} else if (bug[0] == c) {
stack[++idx] = state;
state = 1;
} else {
if(state > 0) {
stack[++idx] = state;
}
for(int i = 0; i <= idx; i++) {
state = stack[i];
for (int j = 0; j < state; j++) {
}
}
state = 0;
idx = -1;
}
}
}
}
}