#include <iostream>
#include <string>
using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    string a, b;
    cin >> a >> b;

    int i = 0;
    bool ok = true;
    for (int j = 0; j < m; j++) {
        if (i < n && a[i] == b[j]) {
            i++;
        }
        if (i == n) {
            cout << "YES\n";
            ok = false;
            break;
        }
    }
    if(ok == true){
        cout << "NO";
    }
    return 0;
}
