import java.util.*;
import java.lang.*;
import java.io.*;

// The main method must be in a class named "Main".
class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int k=sc.nextInt();

        String str1=sc.next();
        String str2=sc.next();

        Set<String> set1=new HashSet<>();
        for(int i=0;i<=str1.length()-k;i++){
            set1.add(str1.substring(i,i+k));
        }


        int count=0;
        
        for(int i=0;i<=(str2.length()-k);i++){
            String result=str2.substring(i,i+k);
            if(set1.contains(result)) count++;
        }

        System.out.println(count);
        
    }
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: