#include <bits/stdc++.h>
using namespace std;
int main(){
	int l1,l2,x = 0,lastpos = -1,inklen = 0,lockpos = -1,genelock = 0;
	string dna,fat;
	cin >> l1 >> l2 >> dna >> fat;
	while (dna.find(fat,x) != dna.npos){
		x = dna.find(fat,x);
		if (x > lockpos){
			genelock++;
			lockpos = x + fat.size() - 1;
		}
		if (lastpos < x) inklen += fat.size();
		else inklen += x + fat.size() - 1 - lastpos;
		lastpos = x + fat.size() - 1;
		x++;
	}
	cout << inklen << " " << genelock << endl;
	return 0;
}