import java.util.Collections;
import java.util.Map;

    import java.util.Scanner;
import java.util.TreeMap;

    public class Codeforces {

        public static void main(String[] args) {
            Scanner sc = new Scanner(System.in);
            int n = sc.nextInt();
            TreeMap<Integer,Integer> hmap = new TreeMap<>(Collections.reverseOrder());
            int arr [] = new int[n];
            for(int i = 0;i < n; i++){
               int a = sc.nextInt();
               if(hmap.containsKey(a)){
                   hmap.put(a, hmap.get(a) + 1);
            }
               else {
                   hmap.put(a, 1);
               }
               arr[i] = a;
            }
            int groups = 0;
           for(Map.Entry e: hmap.entrySet()){
               int a = (int)e.getKey();
               int count = (int)e.getValue();
              while( count > 0){
                  if(a == 4){
                     groups += count;
                     count = 0;
                    hmap.put(a, count);
                  }
                  if(a == 3){
                      if(!hmap.containsKey(1)){
                         groups += count;
                         count = 0;
                        hmap.put(a, count);
                      }
                      else{
                          groups += count;
                          hmap.put(1, hmap.get(1) - count);
                          count = 0;
                        hmap.put(a, count);
                      }
                  }
                  if(a == 2){
                      if(count % 2 != 0){
                          if(hmap.containsKey(1) && hmap.get(1) > 0){
                              if(hmap.get(1) >= 2 ){
                                  groups += 1;
                                  hmap.put(1, hmap.get(1) - 2);
                                  count -= 1;
                              }
                              else{
                              count -= 1;
                              hmap.put(1, hmap.get(1) - 1);
                              groups += 1;
                                }}
                          else {
                              count -= 1;
                              groups += 1;
                          }
                      }
                      groups += count/2;
                      count = 0;
                      hmap.put(2, count);
                  }
                  if(a == 1){
                      if(count >= 4){
                      groups += count / 4 + count % 4;
                      count = 0;
                    }
                      else{
                          groups += 1;
                          count = 0;
                      }
                    }
                }
           }
            System.out.println(groups);
        }
    }


import java.util.Collections;
import java.util.Map;

    import java.util.Scanner;
import java.util.TreeMap;

    public class Codeforces {

        public static void main(String[] args) {
            Scanner sc = new Scanner(System.in);
            int n = sc.nextInt();
            TreeMap<Integer,Integer> hmap = new TreeMap<>(Collections.reverseOrder());
            int arr [] = new int[n];
            for(int i = 0;i < n; i++){
               int a = sc.nextInt();
               if(hmap.containsKey(a)){
                   hmap.put(a, hmap.get(a) + 1);
            }
               else {
                   hmap.put(a, 1);
               }
               arr[i] = a;
            }
            int groups = 0;
           for(Map.Entry e: hmap.entrySet()){
               int a = (int)e.getKey();
               int count = (int)e.getValue();
              while( count > 0){
                  if(a == 4){
                     groups += count;
                     count = 0;
                    hmap.put(a, count);
                  }
                  if(a == 3){
                      if(!hmap.containsKey(1)){
                         groups += count;
                         count = 0;
                        hmap.put(a, count);
                      }
                      else{
                          groups += count;
                          hmap.put(1, hmap.get(1) - count);
                          count = 0;
                        hmap.put(a, count);
                      }
                  }
                  if(a == 2){
                      if(count % 2 != 0){
                          if(hmap.get(1) > 0){
                              count -= 1;
                              hmap.put(1, hmap.get(1) - 1);
                              groups += 1;
                          }
                          else {
                              count -= 1;
                              groups += 1;
                          }
                      }
                      groups += count/2;
                      count = 0;
                      hmap.put(2, count);
                  }
                  if(a == 1){
                      groups += count / 4 + count % 4;
                      count = 0;
                  }
              }
           }
            System.out.println(groups);
        }
    }


import java.util.*;

public class Taxi {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int numOfGroup = scanner.nextInt();

        String[] numOfChildren = new String[numOfGroup];
        double countOfGroupHasOnePerson = 0;
        double countOfGroupHasTwoPerson = 0;
        double countOfGroupHasThreePerson = 0;
        double countOfGroupHasFourPerson = 0;

        int numOfCars = 0;

        scanner.nextLine();
        numOfChildren = scanner.nextLine().split(" ");

        for (int i = 0; i < numOfGroup; i++) {
            switch (Integer.parseInt(numOfChildren[i])) {
                case 4: {
                    countOfGroupHasFourPerson += 1;
                    break;
                }
                case 3: {
                    countOfGroupHasThreePerson += 1;
                    break;
                }
                case 2: {
                    countOfGroupHasTwoPerson += 1;
                    break;
                }
                case 1: {
                    countOfGroupHasOnePerson += 1;
                    break;
                }
            }
        }

        numOfCars += countOfGroupHasFourPerson;
        numOfCars += countOfGroupHasThreePerson;

        countOfGroupHasOnePerson = countOfGroupHasOnePerson - countOfGroupHasThreePerson > 0
                ? countOfGroupHasOnePerson - countOfGroupHasThreePerson : 0;

        if (countOfGroupHasTwoPerson % 2 == 0) {
            numOfCars += countOfGroupHasTwoPerson / 2;
        } else {
            numOfCars += Math.ceil(countOfGroupHasTwoPerson / 2);

            countOfGroupHasOnePerson = countOfGroupHasOnePerson >= 2 ? countOfGroupHasOnePerson - 2 : 0;
        }

        numOfCars += countOfGroupHasOnePerson;
        System.out.println(numOfCars);
    }
}


import java.util.*;

public class Taxi {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int numOfGroup = scanner.nextInt();

        String[] numOfChildren = new String[numOfGroup];
        double countOfGroupHasOnePerson = 0;
        double countOfGroupHasTwoPerson = 0;
        double countOfGroupHasThreePerson = 0;
        double countOfGroupHasFourPerson = 0;

        int numOfCars = 0;

        scanner.nextLine();
        numOfChildren = scanner.nextLine().split(" ");

        for (int i = 0; i < numOfGroup; i++) {
            switch (Integer.parseInt(numOfChildren[i])) {
                case 4: {
                    countOfGroupHasFourPerson += 1;
                    break;
                }
                case 3: {
                    countOfGroupHasThreePerson += 1;
                    break;
                }
                case 2: {
                    countOfGroupHasTwoPerson += 1;
                    break;
                }
                case 1: {
                    countOfGroupHasOnePerson += 1;
                    break;
                }
            }
        }

            numOfCars += countOfGroupHasFourPerson;
            numOfCars += countOfGroupHasThreePerson;

            countOfGroupHasOnePerson = countOfGroupHasOnePerson - countOfGroupHasThreePerson > 0
                    ? countOfGroupHasOnePerson - countOfGroupHasThreePerson : 0;

            numOfCars += countOfGroupHasTwoPerson % 2 == 0
                    ? countOfGroupHasTwoPerson / 2 : Math.ceil(countOfGroupHasTwoPerson / 2);

            numOfCars += countOfGroupHasOnePerson % 4 == 0
                    ? countOfGroupHasOnePerson / 4 : Math.floor(countOfGroupHasOnePerson / 4);

        System.out.println(numOfCars);
    }
}


import java.util.*;

public class Taxi {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int numOfGroup = scanner.nextInt();

        String[] numOfChildren = new String[numOfGroup];
        double countOfGroupHasOnePerson = 0;
        double countOfGroupHasTwoPerson = 0;
        double countOfGroupHasThreePerson = 0;
        double countOfGroupHasFourPerson = 0;

        int numOfCars = 0;

        scanner.nextLine();
        numOfChildren = scanner.nextLine().split(" ");

        for (int i = 0; i < numOfGroup; i++) {
            switch (Integer.parseInt(numOfChildren[i])) {
                case 4: {
                    countOfGroupHasFourPerson += 1;
                    break;
                }
                case 3: {
                    countOfGroupHasThreePerson += 1;
                    break;
                }
                case 2: {
                    countOfGroupHasTwoPerson += 1;
                    break;
                }
                case 1: {
                    countOfGroupHasOnePerson += 1;
                    break;
                }
            }
        }

            numOfCars += countOfGroupHasFourPerson;
            numOfCars += countOfGroupHasThreePerson;

            countOfGroupHasOnePerson = countOfGroupHasOnePerson - countOfGroupHasThreePerson > 0
                    ? countOfGroupHasOnePerson - countOfGroupHasThreePerson : countOfGroupHasOnePerson;

            numOfCars += countOfGroupHasTwoPerson % 2 == 0
                    ? countOfGroupHasTwoPerson / 2 : Math.ceil(countOfGroupHasTwoPerson / 2);

            numOfCars += countOfGroupHasOnePerson % 4 == 0
                    ? countOfGroupHasOnePerson / 4 : Math.ceil(countOfGroupHasOnePerson / 4);

        System.out.println(numOfCars);
    }
}


import java.util.*;

public class Taxi {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int numOfGroup = scanner.nextInt();

        String[] numOfChildren = new String[numOfGroup];
        double countOfGroupHasOnePerson = 0;
        double countOfGroupHasTwoPerson = 0;
        double countOfGroupHasThreePerson = 0;
        double countOfGroupHasFourPerson = 0;

        int numOfCars = 0;

        scanner.nextLine();
        numOfChildren = scanner.nextLine().split(" ");

        for (int i = 0; i < numOfGroup; i++) {
            switch (Integer.parseInt(numOfChildren[i])) {
                case 4: {
                    countOfGroupHasFourPerson += 1;
                    break;
                }
                case 3: {
                    countOfGroupHasThreePerson += 1;
                    break;
                }
                case 2: {
                    countOfGroupHasTwoPerson += 1;
                    break;
                }
                case 1: {
                    countOfGroupHasOnePerson += 1;
                    break;
                }
            }
        }

        numOfCars += countOfGroupHasFourPerson;
        numOfCars += countOfGroupHasThreePerson;

        countOfGroupHasOnePerson = countOfGroupHasOnePerson - countOfGroupHasThreePerson > 0
                ? countOfGroupHasOnePerson - countOfGroupHasThreePerson : 0;

        numOfCars += countOfGroupHasTwoPerson % 2 == 0
                ? countOfGroupHasTwoPerson / 2 : Math.ceil(countOfGroupHasTwoPerson / 2);

        if (countOfGroupHasOnePerson == 1) {
            numOfCars += countOfGroupHasOnePerson;
        }

        numOfCars += countOfGroupHasOnePerson % 4 == 0
                ? countOfGroupHasOnePerson / 4 : Math.floor(countOfGroupHasOnePerson / 4);

        System.out.println(numOfCars);
    }
}


import java.util.*;

public class Taxi {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int numOfGroup = scanner.nextInt();

        String[] numOfChildren = new String[numOfGroup];
        int countOfGroupHasOnePerson = 0;
        int countOfGroupHasTwoPerson = 0;
        int countOfGroupHasThreePerson = 0;
        int countOfGroupHasFourPerson = 0;

        int numOfCars = 0;

        scanner.nextLine();
        numOfChildren = scanner.nextLine().split(" ");

        for (int i = 0; i < numOfGroup; i++) {
            switch (Integer.parseInt(numOfChildren[i])) {
                case 4: {
                    countOfGroupHasFourPerson += 1;
                    break;
                }
                case 3: {
                    countOfGroupHasThreePerson += 1;
                    break;
                }
                case 2: {
                    countOfGroupHasTwoPerson += 1;
                    break;
                }
                case 1: {
                    countOfGroupHasOnePerson += 1;
                    break;
                }
            }
        }

        if (countOfGroupHasOnePerson == 0) {
            numOfCars += countOfGroupHasFourPerson;
            numOfCars += countOfGroupHasThreePerson;
            numOfCars += countOfGroupHasTwoPerson % 2 == 0 ? countOfGroupHasTwoPerson / 2 : Math.ceil(countOfGroupHasTwoPerson / 2);
        } else if (countOfGroupHasOnePerson % 4 == 0) {
            numOfCars += countOfGroupHasFourPerson;
            numOfCars += countOfGroupHasThreePerson;
            numOfCars += countOfGroupHasTwoPerson % 2 == 0 ? countOfGroupHasTwoPerson / 2 : Math.ceil(countOfGroupHasTwoPerson / 2);
            numOfCars += countOfGroupHasOnePerson / 4;
        } else if (countOfGroupHasOnePerson % 2 == 0) {
            numOfCars += countOfGroupHasFourPerson;
            numOfCars += countOfGroupHasThreePerson;
            numOfCars += (countOfGroupHasTwoPerson) % 2 == 0 ? countOfGroupHasTwoPerson / 2 : Math.ceil(countOfGroupHasTwoPerson / 2);
            numOfCars += Math.floor(countOfGroupHasOnePerson / 4);
        } else if (countOfGroupHasOnePerson % 2 != 0) {
            numOfCars += countOfGroupHasFourPerson;
            numOfCars += countOfGroupHasThreePerson;
            numOfCars += (countOfGroupHasTwoPerson) % 2 == 0 ? countOfGroupHasTwoPerson / 2 : Math.ceil(countOfGroupHasTwoPerson / 2);
            numOfCars += Math.ceil(countOfGroupHasOnePerson / 4);
        }

        System.out.println(numOfCars);
    }
}


import java.util.*;

public class Taxi {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int numOfGroup = scanner.nextInt();

        String[] numOfChildren = new String[numOfGroup];
        double countOfGroupHasOnePerson = 0;
        double countOfGroupHasTwoPerson = 0;
        double countOfGroupHasThreePerson = 0;
        double countOfGroupHasFourPerson = 0;

        int numOfCars = 0;

        scanner.nextLine();
        numOfChildren = scanner.nextLine().split(" ");

        for (int i = 0; i < numOfGroup; i++) {
            switch (Integer.parseInt(numOfChildren[i])) {
                case 4: {
                    countOfGroupHasFourPerson += 1;
                    break;
                }
                case 3: {
                    countOfGroupHasThreePerson += 1;
                    break;
                }
                case 2: {
                    countOfGroupHasTwoPerson += 1;
                    break;
                }
                case 1: {
                    countOfGroupHasOnePerson += 1;
                    break;
                }
            }
        }

        numOfCars += countOfGroupHasFourPerson;
        numOfCars += countOfGroupHasThreePerson;

        countOfGroupHasOnePerson = countOfGroupHasOnePerson - countOfGroupHasThreePerson > 0
                ? countOfGroupHasOnePerson - countOfGroupHasThreePerson : 0;

        numOfCars += Math.ceil(countOfGroupHasTwoPerson / 2);

        if (countOfGroupHasOnePerson == 1 && countOfGroupHasTwoPerson == 0) {
            numOfCars += countOfGroupHasOnePerson;
        } else {
            numOfCars += countOfGroupHasOnePerson % 4 == 0
                    ? countOfGroupHasOnePerson / 4 : Math.floor(countOfGroupHasOnePerson / 4);
        }

        System.out.println(numOfCars);
    }
}


import java.util.*;

public class Taxi {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int numOfGroup = scanner.nextInt();

        int[] numOfChildren = new int[numOfGroup];
        int sumOfChildren = 0;
        int numOfCars = 0;

        for (int i = 0; i < numOfGroup; i++) {
            numOfChildren[i] = scanner.nextInt();
            numOfChildren[i] = Math.abs(numOfChildren[i] - 4);
        }

        for (int i = 0; i < numOfGroup; i++) {
            sumOfChildren += numOfChildren[i];
        }
        numOfCars = (int) Math.ceil(sumOfChildren / 4);

        System.out.println(numOfCars);
    }
}


import java.util.*;

public class Taxi {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int numOfGroup = scanner.nextInt();

        int[] numOfChildren = new int[numOfGroup];
        int sumOfChildren = 0;
        int numOfCars = 0;

        // Store inputs.
        for (int i = 0; i < numOfGroup; i++) {
            numOfChildren[i] = scanner.nextInt();
        }

        // Sort inputs.
        for (int i = 0; i < numOfGroup; i++) {
            for (int j = 0; j < numOfGroup; j++) {
                if ((j + 1) < numOfGroup && numOfChildren[j] < numOfChildren[j + 1]) {
                    int temp = numOfChildren[j];
                    numOfChildren[j] = numOfChildren[j + 1];
                    numOfChildren[j + 1] = temp;
                }
            }
//            sumOfChildren += numOfChildren[i];
        }

        for (int i = 0; i < numOfGroup; i++) {
            for (int j = i; j < numOfGroup; j++) {
                if (numOfChildren[j] == 4) {
                    numOfCars += 1;
                    return;
                } else if ((j + 1) < numOfGroup && numOfChildren[j] + numOfChildren[j + 1] == 4) {
                    numOfCars += 1;
                    return;

                } else if ((j + 1) < numOfGroup && numOfChildren[j] + numOfChildren[j + 1] <= 4) {
                    if (sumOfChildren <= 4) {
                        sumOfChildren += 1;
                    } else {
                        numOfCars += 1;
                        return;
                    }
                }
            }
        }
        System.out.println(numOfCars);
    }
}


import java.util.*;

public class Taxi {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int numOfGroup = scanner.nextInt();

        int[] numOfChildren = new int[numOfGroup];
        int sumOfChildren = 0;
        int numOfCars = 0;

        for (int i = 0; i < numOfGroup; i++) {
            numOfChildren[i] = scanner.nextInt();
        }

        for (int i = 0; i < numOfGroup; i++) {
            sumOfChildren += numOfChildren[i];
        }

        numOfCars = (int) Math.ceil(sumOfChildren / 4.0);

        System.out.println(numOfCars);
    }
}


import java.util.*;

public class Taxi {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int numOfGroup = scanner.nextInt();

        String[] numOfChildren = new String[numOfGroup];
        double countOfGroupHasOnePerson = 0;
        double countOfGroupHasTwoPerson = 0;
        double countOfGroupHasThreePerson = 0;
        double countOfGroupHasFourPerson = 0;

        int numOfCars = 0;

        scanner.nextLine();
        numOfChildren = scanner.nextLine().split(" ");

        for (int i = 0; i < numOfGroup; i++) {
            switch (Integer.parseInt(numOfChildren[i])) {
                case 4: {
                    countOfGroupHasFourPerson += 1;
                    break;
                }
                case 3: {
                    countOfGroupHasThreePerson += 1;
                    break;
                }
                case 2: {
                    countOfGroupHasTwoPerson += 1;
                    break;
                }
                case 1: {
                    countOfGroupHasOnePerson += 1;
                    break;
                }
            }
        }

        numOfCars += countOfGroupHasFourPerson;
        numOfCars += countOfGroupHasThreePerson;

        countOfGroupHasOnePerson = countOfGroupHasOnePerson - countOfGroupHasThreePerson > 0
                ? countOfGroupHasOnePerson - countOfGroupHasThreePerson : 0;

        numOfCars += Math.ceil(countOfGroupHasTwoPerson / 2);

        if (countOfGroupHasOnePerson == 1 && countOfGroupHasTwoPerson == 0) {
            numOfCars += countOfGroupHasOnePerson;
        }

        numOfCars += countOfGroupHasOnePerson % 4 == 0
                ? countOfGroupHasOnePerson / 4 : Math.floor(countOfGroupHasOnePerson / 4);

        System.out.println(numOfCars);
    }
}


import java.util.*;

public class Taxi {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int numOfGroup = scanner.nextInt();

        String[] numOfChildren = new String[numOfGroup];
        double countOfGroupHasOnePerson = 0;
        double countOfGroupHasTwoPerson = 0;
        double countOfGroupHasThreePerson = 0;
        double countOfGroupHasFourPerson = 0;

        int numOfCars = 0;

        scanner.nextLine();
        numOfChildren = scanner.nextLine().split(" ");

        for (int i = 0; i < numOfGroup; i++) {
            switch (Integer.parseInt(numOfChildren[i])) {
                case 4: {
                    countOfGroupHasFourPerson += 1;
                    break;
                }
                case 3: {
                    countOfGroupHasThreePerson += 1;
                    break;
                }
                case 2: {
                    countOfGroupHasTwoPerson += 1;
                    break;
                }
                case 1: {
                    countOfGroupHasOnePerson += 1;
                    break;
                }
            }
        }

            numOfCars += countOfGroupHasFourPerson;
            numOfCars += countOfGroupHasThreePerson;

            countOfGroupHasOnePerson = countOfGroupHasOnePerson - countOfGroupHasThreePerson > 0
                    ? countOfGroupHasOnePerson - countOfGroupHasThreePerson : countOfGroupHasOnePerson;

            numOfCars += countOfGroupHasTwoPerson % 2 == 0
                    ? countOfGroupHasTwoPerson / 2 : Math.ceil(countOfGroupHasTwoPerson / 2);

            numOfCars += countOfGroupHasOnePerson % 1 == 0
                    ? countOfGroupHasOnePerson / 1 : Math.floor(countOfGroupHasOnePerson / 1);

        System.out.println(numOfCars);
    }
}


import java.util.*;

public class Taxi {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int numOfGroup = scanner.nextInt();

        String[] numOfChildren = new String[numOfGroup];
        double countOfGroupHasOnePerson = 0;
        double countOfGroupHasTwoPerson = 0;
        double countOfGroupHasThreePerson = 0;
        double countOfGroupHasFourPerson = 0;

        int numOfCars = 0;

        scanner.nextLine();
        numOfChildren = scanner.nextLine().split(" ");

        for (int i = 0; i < numOfGroup; i++) {
            switch (Integer.parseInt(numOfChildren[i])) {
                case 4: {
                    countOfGroupHasFourPerson += 1;
                    break;
                }
                case 3: {
                    countOfGroupHasThreePerson += 1;
                    break;
                }
                case 2: {
                    countOfGroupHasTwoPerson += 1;
                    break;
                }
                case 1: {
                    countOfGroupHasOnePerson += 1;
                    break;
                }
            }
        }

        numOfCars += countOfGroupHasFourPerson;
        numOfCars += countOfGroupHasThreePerson;

        countOfGroupHasOnePerson = countOfGroupHasOnePerson - countOfGroupHasThreePerson > 0
                ? countOfGroupHasOnePerson - countOfGroupHasThreePerson : 0;

        if (countOfGroupHasTwoPerson % 2 == 0) {
            numOfCars += countOfGroupHasTwoPerson / 2;
        } else {
            numOfCars += Math.ceil(countOfGroupHasTwoPerson / 2);

            countOfGroupHasOnePerson = countOfGroupHasOnePerson >= 2 ? countOfGroupHasOnePerson - 2 : 0;
        }

        numOfCars += Math.ceil(countOfGroupHasOnePerson / 4);
        System.out.println(numOfCars);
    }
}


n,m=map(int,input().split())
str1=input()
str2=input()
star=str1.find('*')
if star<0:
    if str1==str2:
        print('YES')
    else:
        print('NO')
else:
    if star==0 or str1[:star]==str2[:star]:
        str2=str2[star:]
        if star==len(str1)-1 or str1[star+1:]==str2[-len(str1[star+1:]):]:
            print('YES')
        else:
            print('NO')
    else:
        print('NO')


n,m=map(int,input().split())
str1=input()
str2=input()
star=str1.find('*')
if str1[:star]==str2[:star]:
    str2=str2[star:]
    if str1[star+1:]==str2[-len(str1[star+1:]):]:
        print('YES')
    else:
        print('NO')
else:
    print('NO')


n,m=map(int,input().split())
str1=input()
str2=input()
star=str1.find('*')
if star==0 or str1[:star]==str2[:star]:
    str2=str2[star:]
    if star==len(str1)-1 or str1[star+1:]==str2[-len(str1[star+1:]):]:
        print('YES')
    else:
        print('NO')
else:
    print('NO')


n,m=map(int,input().split())
str1=input()
str2=input()
if str1=='*':
    print('YES')
    import sys
    sys.exit()
star=str1.find('*')
if str1[:star]==str2[:star]:

    str2=str2[star:]
    if str1[star+1:]==str2[-len(str1[star+1:]):]:
        print('YES')
    else:
        print('NO')
else:
    print('NO')


n,m=map(int,input().split())
s=input()
t=input()
for i in range (n):
    if s[i]=="*" and t[0:i]==s[0:i]:
        if i!=n-1 and t[i:-1].find(s[i+1:-1])!=-1:
            print("YES")
        elif i==n-1:
            print("YES")
        break
    elif s[i]=="*" or s.find("*")==-1: print("NO")


import sys
n,m = map(int,input().split())
mask = input()
file = input()
if ('*' not in mask):
    if (mask == file):
        print("YES")
    else:
        print("NO")
    sys.exit()
inx=mask.index('*')
s1 = mask[:inx]
s2 = mask[inx+1:]
if s1 in file and s2 in file:
    ix1 = file.index(s1)
    ix2 = file.rindex(s2)
    if (ix1 == 0 and ix2 == m-len(s2) and ix1+len(s1)-1<ix2):
        print("YES")
    else: print("NO")
else: print("NO")


import sys
n,m = map(int,input().split())
mask = input()
file = input()
if ('*' not in mask):
    if (mask == file):
        print("YES")
    else:
        print("NO")
    sys.exit()
inx=mask.index('*')
s1 = mask[:inx]
s2 = mask[inx+1:]
if s1 in file and s2 in file:
    ix1 = file.index(s1)
    ix2 = file.index(s2)
    if (ix1 == 0 and ix2 == m-len(s2)):
        print("YES")
    else: print("NO")
else: print("NO")


import sys
n,m = map(int,input().split())
mask = input()
file = input()
if ('*' not in mask):
    if (mask == file):
        print("YES")
    else:
        print("NO")
    sys.exit()
inx=mask.index('*')
s1 = mask[:inx]
s2 = mask[inx+1:]
if s1 in file and s2 in file:
    ix1 = file.index(s1)
    ix2 = file.rindex(s2)
    if (ix1 == 0 and ix2 == m-len(s2)):
        print("YES")
    else: print("NO")
else: print("NO")


n,m=map(int,input().split())
s=input()
t=input()
try:
    i=s.index('*')
    Ls,Rs=s[:i],s[i+1:]
    Lt,Rt=t[:i],t[len(t)-len(Rs):]
    if Ls==Lt and Rs==Rt:
        print("YES")
    else:
        print("NO")
except:
    if s==t:
        print("YES")
    else:
        print("NO")


n,m=map(int,input().split())
s=input()
t=input()
if not (s.find('*')):
    i=s.index('*')
    Ls,Rs=s[:i],s[i+1:]
    Lt,Rt=t[:i],t[len(t)-len(Rs):]
    if Ls==Lt and Rs==Rt:
        print("YES")
    else:
        print("NO")
else:
    if s==t:
        print("YES")
    else:
        print("NO")


n,m=map(int,input().split())
s=input()
t=input()
i=s.index('*')
Ls,Rs=s[:i],s[i+1:]
Lt,Rt=t[:i],t[len(t)-len(Rs):]
if Ls==Lt and Rs==Rt:
    print("YES")
else:
    print("NO")


n,m=map(int,input().split())
s=input()
t=input()
try:
    i=s.index('*')
    Ls,Rs=s[:i],s[i+1:]
    Lt,Rt=t[:i],t[len(t)-len(Rs):]
    if Ls==Lt and Rs==Rt:
        if len(Lt+Rt)>len(Ls+Rs):
            print("NO")
        else:
            print("YES")
    else:
        print("NO")
except:
    if s==t:
        print("YES")
    else:
        print("NO")


n,k=map(int,input().split())
if k<=n:
    if k%2==0:
        print(k//2-1)
    else:
        print(k//2)
else:
    print(max(0,n-k//2))


n,k=map(int,input().split())
if k<n:
    print(k//2)
else:
    if k==n and k%2==0:
        print(k//2-1)
    else:
        print(max(0,n-k//2))


n,m=map(int,input().split())
s=input()
t=input()
try:
    i=s.index('*')
    Ls,Rs=s[:i],s[i+1:]
    Lt,Rt=t[:i],t[len(t)-len(Rs):]
    if Ls==Lt and Rs==Rt:
        if Lt+Rt!=t:
            print("NO")
        else:
            print("YES")
    else:
        print("NO")
except:
    if s==t:
        print("YES")
    else:
        print("NO")


n,m=map(int,input().split())
s=input()
t=input()
try:
    i=s.index('*')
    Ls,Rs=s[:i],s[i+1:]
    Lt,Rt=t[:i],t[len(t)-len(Rs):]
    if Ls==Lt and Rs==Rt:
        if len(Lt+Rt)>len(t):
            print("NO")
        else:
            print("YES")
    else:
        print("NO")
except:
    if s==t:
        print("YES")
    else:
        print("NO")


n,m = map(int,input().split())

s = input()
t = input()

s1 = s[:s.index('*')]
s2 = s[s.index('*')+1:]

if (t.index(s1)==0) & (t.index(s2)==len(t)-len(s2)) & (t.index(s1)+len(s1)<=t.index(s2)):
	print('YES')
else:
	print('NO')


n,m = map(int,input().split())

s = input()
t = input()

if s.count('*')==1:
	s1 = s[:s.index('*')]
	s2 = s[s.index('*')+1:]
	try:
		if (t.index(s1)==0) & (t.index(s2)==len(t)-len(s2)) & (t.index(s1)+len(s1)<=t.index(s2)):
			print('YES')
		else:
			print('NO')
	except:
		if (n==m==1) & (s=='*'):
			print('YES')
		else:
			print('NO')
else:
	if s==t:
		print('YES')
	else:
		print('NO')


n,m = map(int,input().split())

s = input()
t = input()

if s.count('*')==1:
	if (t.startswith(s[:s.index('*')])) & (t[len(s[:s.index('*')]):].endswith(s[s.index('*')+1:])):
		print('YES')
	else:
		print('NO')
else:
	if s==t:
		print('YES')
	else:
		print('NO')


n,m = map(int,input().split())

s = input()
t = input()

if s.count('*')==1:
	s1 = s[:s.index('*')]
	s2 = s[s.index('*')+1:]
	try:
		if (t.index(s1)==0) & (t.index(s2)==len(t)-len(s2)) & (t.index(s1)+len(s1)<=t.index(s2)):
			print('YES')
		else:
			print('NO')
	except:
		print('NO')
else:
	if s==t:
		print('YES')
	else:
		print('NO')


n,m = map(int,input().split())

s = input()
t = input()

if s.count('*')==1:
	s1 = s[:s.index('*')]
	s2 = s[s.index('*')+1:]
	if (t.index(s1)==0) & (t.index(s2)==len(t)-len(s2)) & (t.index(s1)+len(s1)<=t.index(s2)):
		print('YES')
	else:
		print('NO')
else:
	if s==t:
		print('YES')
	else:
		print('NO')


n,m = map(int,input().split())

s = input()
t = input()

s1 = s[:s.index('*')]
s2 = s[s.index('*')+1:]

if (t.index(s1)==0) & (t.index(s2)==len(t)-len(s2)) & (t.index(s1)+len(s1)<t.index(s2)):
	print('YES')
else:
	print('NO')


n,m=map(int,input().split())
a=input()
b=input()
c=1
if n>m and a.count('*')==0:
    c=0
if a.count('*')!=0 and n>m+1:
    c=0
for i in range(len(a)):
    if c==0:
        continue
    if a[i]=='*':
        break
    if a[i]!=b[i]:
        c=0
ind =1
for i in range(len(b)-1,-1,-1):
    if c==0:
        continue
    if a[len(a)-ind]=='*':
        break
    if a[len(a)-ind]!=b[i]:
        c=0
    ind+=1
if c==1 and len(a)<=len(b)+1:
    if a.count('*')==0 and n!=m:
        print("NO")
    else:
        print("YES")
else:
    print("NO")


n,m=map(int,input().split())
a=input()
b=input()
c=1
for i in range(len(a)):
    if a[i]=='*':
        break
    if a[i]!=b[i]:
        c=0
ind =1
for i in range(len(b)-1,-1,-1):
    if a[len(a)-ind]=='*':
        break
    if a[len(a)-ind]!=b[i]:
        c=0
    ind+=1
if c==1 and len(a)<=len(b)+1:
    print("YES")
else:
    print("NO")


n,m=map(int,input().split())
a=input()
b=input()
c=1
if n>m:
    c=0
for i in range(len(a)):
    if c==0:
        continue
    if a[i]=='*':
        break
    if a[i]!=b[i]:
        c=0
ind =1
for i in range(len(b)-1,-1,-1):
    if c==0:
        continue
    if a[len(a)-ind]=='*':
        break
    if a[len(a)-ind]!=b[i]:
        c=0
    ind+=1
if c==1 and len(a)<=len(b)+1:
    print("YES")
else:
    print("NO")


n,m=map(int,input().split())
a=input()
b=input()
c=1
if n>m and a.count('*')==0:
    c=0
if a.count('*')!=0 and n>m+1:
    c=0
for i in range(len(a)):
    if c==0:
        continue
    if a[i]=='*':
        break
    if a[i]!=b[i]:
        c=0
ind =1
for i in range(len(b)-1,-1,-1):
    if c==0:
        continue
    if a[len(a)-ind]=='*':
        break
    if a[len(a)-ind]!=b[i]:
        c=0
    ind+=1
if c==1 and len(a)<=len(b)+1:
    print("YES")
else:
    print("NO")


n,m=map(int,input().split())
a=input()
b=input()
c=1
if n!=m and a.count('*')==0:
    c=0
if a.count('*')!=0 and n>m+1:
    c=0
for i in range(len(a)):
    if c==0:
        continue
    if a[i]=='*':
        break
    if a[i]!=b[i]:
        c=0
ind =1
for i in range(len(b)-1,-1,-1):
    if c==0:
        continue
    if a[len(a)-ind]=='*':
        break
    if a[len(a)-ind]!=b[i]:
        c=0
    ind+=1
if c==1 and len(a)<=len(b)+1:
    print("YES")
else:
    print("NO")


input()
s = input()
t = input()
if '*' in s:
    s1, s2 = s.split('*')
    # print(t[:len(s1)] == s1,  t[-len(s2):] == s2, len(t) >= len(s1) + len(s2))
    if (t[:len(s1)] == s1 or s1 == '') and (t[-len(s2):] == s2 or s2 == '') and len(t) >= len(s1) + len(s2):
        print('YES')
    else:
        print('NO')
else:
    if t == s:
        print('YES')
    else:
        print('NO')


input()
s = input()
t = input()
if '*' in s:
    s1, s2 = s.split('*')
    # print(t[:len(s1)] == s1,  t[-len(s2):] == s2, len(t) >= len(s1) + len(s2))
    if t[:len(s1)] == s1 and t[-len(s2):] == s2 and len(t) >= len(s1) + len(s2):
        print('YES')
    else:
        print('NO')
else:
    if t == s:
        print('YES')
    else:
        print('NO')


input()
s = input()
t = input()
s1, s2 = s.split('*')
# print(t[:len(s1)] == s1,  t[-len(s2):] == s2, len(t) >= len(s1) + len(s2))
if t[:len(s1)] == s1 and t[-len(s2):] == s2 and len(t) >= len(s1) + len(s2):
    print('YES')
else:
    print('NO')


input()
s = input()
t = input()
if '*' in s:
    if s == '*':
        print('YES')
        exit(0)
    s1, s2 = s.split('*')
    # print(t[:len(s1)] == s1,  t[-len(s2):] == s2, len(t) >= len(s1) + len(s2))
    if t[:len(s1)] == s1 and t[-len(s2):] == s2 and len(t) >= len(s1) + len(s2):
        print('YES')
    else:
        print('NO')
else:
    if t == s:
        print('YES')
    else:
        print('NO')


n,k=map(int,input().split())
w=input().split('*')
y=input()
if n>k+1:
    print('NO')
else:
    if w[0]==y[:len(w[0])] and w[1]==y[k-len(w[1]):]:
        print('YES')
    else:
        print('NO')


n,k=map(int,input().split())
w=input().split('*')
y=input()
if n<k:
    print('NO')
else:
    if w[0]==y[:len(w[0])] and w[1]==y[k-len(w[1]):]:
        print('YES')
    else:
        print('NO')


n,k=map(int,input().split())
p=input()
y=input()
if '*' not in p:
    if p==y:
        print('YES')
        quit()
    else:
        print('NO')
        quit()

w=p.split('*')

if n>k+1:
    print('NO')

else:
    if w[0]==y[:len(w[0])] and w[1]==y[k-len(w[1]):]:
        print('YES')
    else:
        print('NO')


n,k=map(int,input().split())
w=input()
y=input()
for i in range(n):
    if w[i]=='*':
        break
if y[:i]!=w[:i]:
    print('NO')
else:
    flag=True
    try:
        for j in range(k-1,i,-1):
            if w[i+1:]==y[j:]:
                flag=False
                break
    except:
        pass

    if flag==False:
        print('YES')
    else:
        print('NO')


n,k=map(int,input().split())
w=input()
y=input()
for i in range(n):
    if w[i]=='*':
        break
if y[:i]!=w[:i]:
    print('NO')
else:
    flag=True
    try:
        for j in range(k-1,i-1,-1):
            if w[i+1:]==y[j:]:
                flag=False
                break
    except:
        pass

    if flag==False:
        print('YES')
    else:
        print('NO')


n,k=map(int,input().split())
w=input().split('*')
y=input()
if n>k:
    print('NO')
else:
    if w[0]==y[:len(w[0])] and w[1]==y[k-len(w[1]):]:
        print('YES')
    else:
        print('NO')


n,k = map(int,input().split())
s = input().split('*')
t = input()
if len(s) == 1:
	print('YES' if s[0] == t else 'NO')
else:
	print('YES' if t[:len(s[0])] == s[0] and t[-len(s[1]):] == s[1] and n <= k else 'NO')
	# print(t[:len(s[0])],t[-len(s[1]):])
	# print(s[0],s[1])


n,k = map(int,input().split())
s = input().split('*')
t = input()
if len(s) == 1:
	print('YES' if s[0] == t else 'NO')
else:
	print('YES' if t[:len(s[0])] == s[0] and t[-len(s[1]):] == s[1] and n <= k+1 else 'NO')
	# print(t[:len(s[0])],t[-len(s[1]):])
	# print(s[0],s[1])


import re
n,k = map(int,input().split())
s = input().split('*')
t = input()
if len(s) == 1:
	print('YES' if s[0] == t else 'NO')
else:
	r = re.search("^%s.*%s$" % (s[0],s[1]), t)
	print('NO' if r == None else 'YES')


n,k = map(int,input().split())
s = input().split('*')
t = input()
if len(s) == 1:
	print('YES' if s[0] == t else 'NO')
else:
	print('YES' if t[:len(s[0])] == s[0] and (t[-len(s[1]):] == s[1] if s[1] != '' else True) and n <= k+1 else 'NO')
	# print(t[:len(s[0])],t[-len(s[1]):])
	# print(s[0],s[1])
	# print(s)


from string import printable
#print(printable[10:36])
n,m = (input().split(" "))
#n=int(input())
#m=int(input())
#s,t = (input().split(" "))
s=(input())
t=(input())
if int(n)>int(int(m)+1):
    print("NO")
    exit(0)
if int(n)<=int(int(m)+1):
    if '*' in s:
        x = s.split('*')
        if x[0] in t and x[1] in t:
            print("YES")
    else:
        if s!=t:
            print("NO")
        else:
            print("YES")


from string import printable
#print(printable[10:36])
n,m = (input().split(" "))
#n=int(input())
#m=int(input())
#s,t = (input().split(" "))
s=(input())
t=(input())
if int(n)>int(int(m)+1):
    print("NO")
    exit(0)
if int(n)<=int(int(m)+1):
    if '*' in s:
        x = s.split('*')
        y = t.split(str(x[0]))[1]
        z = y.split(str(x[1]))[0]
        #if s==y+z:

        print("YES")
    else:
        if s!=t:
            print("NO")
        else:
            print("YES")


from string import printable
#print(printable[10:36])
n,m = (input().split(" "))
#n=int(input())
#m=int(input())
#s,t = (input().split(" "))
s=(input())
t=(input())
if int(n)>int(int(m)+1):
    print("NO")
    exit(0)
if int(n)<=int(int(m)+1):
    if '*' in s:
        x = s.split('*')
        print(x)
        h=len(x[1] )
        z=len(x[0] )
        #print( t[len(t)-h:] )
        if x[0] == t[:z] and x[1] == t[len(t)-h:] :
            print("YES")
    else:
        if s!=t:
            print("NO")
        else:
            print("YES")


from string import printable
#print(printable[10:36])
n,m = (input().split(" "))
#n=int(input())
#m=int(input())
#s,t = (input().split(" "))
s=(input())
t=(input())
if int(n)>int(int(m)+1):
    print("NO")
    exit(0)
if int(n)<=int(int(m)+1):
    if '*' in s:
        x = s.split('*')
        h=len(x[1] )
        z=len(x[0] )
        if x[0] == t[:h] and x[1] == t[len(t)-z:] :
            print("YES")
    else:
        if s!=t:
            print("NO")
        else:
            print("YES")


from string import printable
#print(printable[10:36])
n,m = (input().split(" "))
#n=int(input())
#m=int(input())
#s,t = (input().split(" "))
s=(input())
t=(input())
if int(n)>int(int(m)+1):
    print("NO")
    exit(0)
if int(n)<=int(int(m)+1):
    if '*' in s:
        x = s.split('*')
        #print(x)
        h=len(x[1] )
        z=len(x[0] )
        #print( t[len(t)-h:] )
        if x[0] == t[:z] and x[1] == t[len(t)-h:] :
            print("YES")
        else:
            print("NO")

    else:
        if s!=t:
            print("NO")
        else:
            print("YES")


from string import printable
#print(printable[10:36])
n,m = (input().split(" "))
#n=int(input())
#m=int(input())
#s,t = (input().split(" "))
s=(input())
t=(input())
if int(n)>int(int(m)+1):
    print("NO")
    exit(0)
if int(n)<=int(int(m)+1):
    if '*' in s:
        x = s.split('*')
        #print(x)
        h=len(x[1] )
        z=len(x[0] )
        #print( t[len(t)-h:] )
        if x[0] == t[:z] and x[1] == t[len(t)-h:] :
            print("YES")
    else:
        if s!=t:
            print("NO")
        else:
            print("YES")


#Stanley Tantysco - 2201814670
#Problem B - Wild Card

def str_limit(n):
    if (n >= 1 and n <= 200000):
        return True
    else:
        return False

def wild_counter(s):
    count=0
    for i in s:
        if i == '*':
            count += 1
    if count <= 1:
        return True
    else:
        return False

limit_in=input()
parse=limit_in.split(' ')
n=int(parse[0])
m=int(parse[1])

s=input()
t=input()

parse2=list(s)
parse3=list(t)
#print(parse2)
#print(parse3)

wildcard=False
wildindex=-1
for i in range(0,len(parse2)):
    if parse2[i]=='*':
        wildcard=True
        wildindex=i
        break

if wildcard:
    temp1=""
    for k in range(wildindex,len(parse3)-1):
        temp1 += parse3[k]

    temp3=s.replace('*',temp1)
    if n <= m:
        if temp3 == t:
            print('Yes')
        else:
            print('No')
    else:
        temp2=s.replace("*","")
        if temp2 == t:
            print('Yes')
        else:
            print('No')
else:
    if s == t:
        print("Yes")
    else:
        print("No")


#Stanley Tantysco - 2201814670
#Problem B - Wild Card

def str_limit(n):
    if (n >= 1 and n <= 200000):
        return True
    else:
        return False

def wild_counter(s):
    count=0
    for i in s:
        if i == '*':
            count += 1
    if count <= 1:
        return True
    else:
        return False

limit_in=input()
parse=limit_in.split(' ')
n=int(parse[0])
m=int(parse[1])

s=input()
t=input()

parse2=list(s)
parse3=list(t)
#print(parse2)
#print(parse3)

wildcard=False
wildindex=-1
for i in range(0,len(parse2)):
    if parse2[i]=='*':
        wildcard=True
        wildindex=i
        break

if wildcard:
    if n <= m:
        temp1=""
        if n == m:
            for i in range(0,len(parse2)):
                if parse2[i] == '*':
                    parse2[i] = parse3[i]
                    temp1 += parse2[i]
            temp3=s.replace('*',temp1)
        else:
            if len(parse2) != 1:
                for j in range(wildindex,len(parse3)-1):
                    temp1 += parse3[j]
                temp3=s.replace('*',temp1)
            else:
                for j in range(wildindex,len(parse3)):
                    temp1 += parse3[j]
                temp3=s.replace('*',temp1)
        if temp3 == t:
            print('Yes')
        else:
            print('No')
    else:
        temp2=s.replace("*","")
        if temp2 == t:
            print('Yes')
        else:
            print('No')
else:
    if s == t:
        print("Yes")
    else:
        print("No")


#Stanley Tantysco - 2201814670
#Problem B - Wild Card

def str_limit(n):
    if (n >= 1 and n <= 200000):
        return True
    else:
        return False

def wild_counter(s):
    count=0
    for i in s:
        if i == '*':
            count += 1
    if count <= 1:
        return True
    else:
        return False

limit_in=input()
parse=limit_in.split(' ')
n=int(parse[0])
m=int(parse[1])

s=input()
t=input()

parse2=list(s)
parse3=list(t)
#print(parse2)
#print(parse3)

wildcard=False
wildindex=-1
firststr=""
laststr=""
for i in range(0,len(parse2)):
    if parse2[i]=='*':
        wildcard=True
        wildindex=i
        firststr=s[:wildindex]
        laststr=s[wildindex+1:len(parse2)]
        break

if wildcard:
    if n <= m:
        temp1=t.replace(laststr,"")
        temp2=temp1.replace(firststr,"")
        temp3=firststr+temp2+laststr
        if temp3 == t:
            print('Yes')
        else:
            print('No')
    else:
        temp2=s.replace("*","")
        if temp2 == t:
            print('Yes')
        else:
            print('No')
else:
    if s == t:
        print("Yes")
    else:
        print("No")


#Stanley Tantysco - 2201814670
#Problem B - Wild Card

def str_limit(n):
    if (n >= 1 and n <= 200000):
        return True
    else:
        return False

def wild_counter(s):
    count=0
    for i in s:
        if i == '*':
            count += 1
    if count <= 1:
        return True
    else:
        return False

limit_in=input()
parse=limit_in.split(' ')
n=int(parse[0])
m=int(parse[1])

s=input()
t=input()

parse2=list(s)
parse3=list(t)
#print(parse2)
#print(parse3)

wildcard=False
wildindex=-1
for i in range(0,len(parse2)):
    if parse2[i]=='*':
        wildcard=True
        wildindex=i
        break

if wildcard:
    temp1=""
    if n == m:
        for i in range(0,len(parse2)):
            if parse2[i] == '*':
                parse2[i] = parse3[i]
                temp1 += parse2[i]
    else:
        if len(parse2) != 1:
            for i in range(wildindex,len(parse2)):
                temp2=s.replace(parse2[i],"")
            for j in range(wildindex,len(parse3)):
                temp1 += parse3[j]
            temp3=temp2.replace('*',temp1)
        else:
            for j in range(wildindex,len(parse3)):
                temp1 += parse3[j]
            temp3=s.replace('*',temp1)
    if n <= m:
        if temp3 == t:
            print('Yes')
        else:
            print('No')
    else:
        temp2=s.replace("*","")
        if temp2 == t:
            print('Yes')
        else:
            print('No')
else:
    if s == t:
        print("Yes")
    else:
        print("No")


#Stanley Tantysco - 2201814670
#Problem B - Wild Card

def str_limit(n):
    if (n >= 1 and n <= 200000):
        return True
    else:
        return False

def wild_counter(s):
    count=0
    for i in s:
        if i == '*':
            count += 1
    if count <= 1:
        return True
    else:
        return False

limit_in=input()
parse=limit_in.split(' ')
n=int(parse[0])
m=int(parse[1])

s=input()
t=input()

parse2=list(s)
parse3=list(t)
#print(parse2)
#print(parse3)

wildcard=False
wildindex=-1
for i in range(0,len(parse2)):
    if parse2[i]=='*':
        wildcard=True
        wildindex=i
        break

if wildcard:
    temp1=""
    if n == m:
        for i in range(0,len(parse2)):
            if parse2[i] == '*':
                parse2[i] = parse3[i]
                temp1 += parse2[i]
    else:
        if len(parse2) != 1:
            for j in range(wildindex,len(parse3)-1):
                temp1 += parse3[j]
            temp3=s.replace('*',temp1)
        else:
            for j in range(wildindex,len(parse3)):
                temp1 += parse3[j]
            temp3=s.replace('*',temp1)
    if n <= m:
        if temp3 == t:
            print('Yes')
        else:
            print('No')
    else:
        temp2=s.replace("*","")
        if temp2 == t:
            print('Yes')
        else:
            print('No')
else:
    if s == t:
        print("Yes")
    else:
        print("No")


#Stanley Tantysco - 2201814670
#Problem B - Wild Card

def str_limit(n):
    if (n >= 1 and n <= 200000):
        return True
    else:
        return False

def wild_counter(s):
    count=0
    for i in s:
        if i == '*':
            count += 1
    if count <= 1:
        return True
    else:
        return False

limit_in=input()
parse=limit_in.split(' ')
n=int(parse[0])
m=int(parse[1])

s=input()
t=input()

parse2=list(s)
parse3=list(t)
#print(parse2)
#print(parse3)

wildcard=False
wildindex=-1
for i in range(0,len(parse2)):
    if '*' in parse2:
        wildcard=True
        wildindex=1
        break

if wildcard:
    temp1=""
    temp2=""
    temp3=""
    for i in range(0,wildindex):
        temp1 += parse2[i]
    for j in range(0,wildindex):
        temp2 += parse3[j]
    for k in range(wildindex,len(parse3)):
        temp3 += parse3[k]
    temp4=parse2[n-1]
    temp5=parse3[m-1]
    if temp1 == temp2 and temp4 == temp5:
        print('Yes')
    else:
        print('No')
else:
    if s == t:
        print("Yes")
    else:
        print("No")


#Stanley Tantysco - 2201814670
#Problem B - Wild Card

def str_limit(n):
    if (n >= 1 and n <= 200000):
        return True
    else:
        return False

def wild_counter(s):
    count=0
    for i in s:
        if i == '*':
            count += 1
    if count <= 1:
        return True
    else:
        return False

limit_in=input()
parse=limit_in.split(' ')
n=int(parse[0])
m=int(parse[1])

s=input()
t=input()

parse2=list(s)
parse3=list(t)
#print(parse2)
#print(parse3)

wildcard=False
wildindex=-1
for i in range(0,len(parse2)):
    if parse2[i]=='*':
        wildcard=True
        wildindex=i
        break

if wildcard:
    temp1=""
    if n == m:
        for i in range(0,len(parse2)):
            if parse2[i] == '*':
                parse2[i] = parse3[i]
                temp1 += parse2[i]
    else:
        for j in range(wildindex,len(parse3)-1):
            temp1 += parse3[j]
    temp3=s.replace('*',temp1)
    if n <= m:
        if temp3 == t:
            print('Yes')
        else:
            print('No')
    else:
        temp2=s.replace("*","")
        if temp2 == t:
            print('Yes')
        else:
            print('No')
else:
    if s == t:
        print("Yes")
    else:
        print("No")


#Stanley Tantysco - 2201814670
#Problem B - Wild Card

def str_limit(n):
    if (n >= 1 and n <= 200000):
        return True
    else:
        return False

def wild_counter(s):
    count=0
    for i in s:
        if i == '*':
            count += 1
    if count <= 1:
        return True
    else:
        return False

limit_in=input()
parse=limit_in.split(' ')
n=int(parse[0])
m=int(parse[1])

s=input()
t=input()

parse2=list(s)
parse3=list(t)
#print(parse2)
#print(parse3)

wildcard=False
wildindex=-1
firststr=""
laststr=""
for i in range(0,len(parse2)):
    if parse2[i]=='*':
        wildcard=True
        wildindex=i
        firststr=s[:wildindex]
        laststr=s[wildindex+1:len(parse2)]
        break

if wildcard:
    if n <= m:
        if s[0] == '*':
            temp1=t[:len(t)-1]
            temp3=temp1+laststr
        elif s[len(parse2)-1] == '*':
            temp1=t[len(t)-1:len(t)]
            temp3=firststr+temp1
        else:
            temp1=t.replace(laststr,"")
            temp2=temp1.replace(firststr,"")
            temp3=firststr+temp2+laststr

        if temp3 == t:
            print('Yes')
        else:
            print('No')
    else:
        temp2=s.replace("*","")
        if temp2 == t:
            print('Yes')
        else:
            print('No')
else:
    if s == t:
        print("Yes")
    else:
        print("No")


#Stanley Tantysco - 2201814670
#Problem B - Wild Card

def str_limit(n):
    if (n >= 1 and n <= 200000):
        return True
    else:
        return False

def wild_counter(s):
    count=0
    for i in s:
        if i == '*':
            count += 1
    if count <= 1:
        return True
    else:
        return False

limit_in=input()
parse=limit_in.split(' ')
n=int(parse[0])
m=int(parse[1])

s=input()
t=input()

parse2=list(s)
parse3=list(t)
#print(parse2)
#print(parse3)
if n == m:
    if '*' not in parse2:
        if s == t:
            print('Yes')
        else:

            print('No')
    else:
        index=-1
        for i in range(0,len(parse2)):
            if parse2[i] == '*':
               index=i
               break
        x = slice(index)

        temp1 = ""
        for i in range(0,index):
            temp1 += parse2[i]

        temp2= ""
        for j in range(0,index):
            temp2 += parse3[j]

        if temp1 == temp2:
            print('Yes')
        else:
            print('No')
elif n > m:
    temp = ""
    parse2.remove('*')
    for i in parse2:
        temp += i
    #print(temp)
    if temp == t:
        print('Yes')
    else:
        print('No')
else:
    index=-1
    for i in range(0,len(parse2)):
        if parse2[i] == '*':
           index=i
           break
    x = slice(index)

    temp1 = ""
    for i in range(0,index):
        temp1 += parse2[i]

    temp2= ""
    for j in range(0,index):
        temp2 += parse3[j]

    if temp1 == temp2:
        print('Yes')
    else:
        print('No')


#Stanley Tantysco - 2201814670
#Problem B - Wild Card

def str_limit(n):
    if (n >= 1 and n <= 200000):
        return True
    else:
        return False

def wild_counter(s):
    count=0
    for i in s:
        if i == '*':
            count += 1
    if count <= 1:
        return True
    else:
        return False

limit_in=input()
parse=limit_in.split(' ')
n=int(parse[0])
m=int(parse[1])

s=input()
t=input()

parse2=list(s)
parse3=list(t)
#print(parse2)
#print(parse3)

wildcard=False
wildindex=-1
firststr=""
laststr=""
for i in range(0,len(parse2)):
    if parse2[i]=='*':
        wildcard=True
        wildindex=i
        firststr=s[:wildindex]
        laststr=s[wildindex+1:len(parse2)]
        break

if wildcard:
    if n <= m:
        if len(s) != 1:
            if s[0] == '*':
                temp1=t[:len(t)-1]
                temp3=temp1+laststr
            elif s[len(parse2)-1] == '*':
                temp1=t[len(t)-1:len(t)]
                temp3=firststr+temp1
            else:
                temp1=t.replace(laststr,"")
                temp2=temp1.replace(firststr,"")
                temp3=firststr+temp2+laststr
        else:
            temp3=s.replace('*',t)
        if temp3 == t:
            print('Yes')
        else:
            print('No')
    else:
        temp2=s.replace("*","")
        if temp2 == t:
            print('Yes')
        else:
            print('No')
else:
    if s == t:
        print("Yes")
    else:
        print("No")


#Stanley Tantysco - 2201814670
#Problem B - Wild Card

def str_limit(n):
    if (n >= 1 and n <= 200000):
        return True
    else:
        return False

def wild_counter(s):
    count=0
    for i in s:
        if i == '*':
            count += 1
    if count <= 1:
        return True
    else:
        return False

limit_in=input()
parse=limit_in.split(' ')
n=int(parse[0])
m=int(parse[1])

s=input()
t=input()

parse2=list(s)
parse3=list(t)
#print(parse2)
#print(parse3)
if n == m:
    if '*' not in parse2:
        if s == t:
            print('Yes')
        else:

            print('No')
    else:
        index=-1
        for i in range(0,len(parse2)):
            if parse2[i] == '*':
               index=i
               break
        x = slice(index)

        temp1 = ""
        for i in range(0,index):
            temp1 += parse2[i]

        temp2= ""
        for j in range(0,index):
            temp2 += parse3[j]

        if temp1 == temp2:
            print('Yes')
        else:
            print('No')
elif n > m:
    temp = ""
    parse2.remove('*')
    for i in parse2:
        temp += i
    #print(temp)
    if temp == t:
        print('Yes')
    else:
        print('No')
else:
    index=-1
    for i in range(0,len(parse2)):
        if parse2[i] == '*':
           index=i
           break
    x = slice(index)

    temp1 = ""
    for i in range(0,index):
        temp1 += parse2[i]

    temp2= ""
    for j in range(0,index):
        temp2 += parse3[j]

    temp3=""
    for a in range(index,len(parse2)):
        temp3 += parse2[a]

    temp4=""
    for b in range(index,len(parse3)):
        temp4 += parse3[b]

    if temp1 == temp2 and temp3 == temp4:
        print('Yes')
    else:
        print('No')


#Stanley Tantysco - 2201814670
#Problem B - Wild Card

def str_limit(n):
    if (n >= 1 and n <= 200000):
        return True
    else:
        return False

def wild_counter(s):
    count=0
    for i in s:
        if i == '*':
            count += 1
    if count <= 1:
        return True
    else:
        return False

limit_in=input()
parse=limit_in.split(' ')
n=int(parse[0])
m=int(parse[1])

s=input()
t=input()

parse2=list(s)
parse3=list(t)
#print(parse2)
#print(parse3)

wildcard=False
wildindex=-1
for i in range(0,len(parse2)):
    if '*' in parse2:
        wildcard=True
        wildindex=1
        break

if wildcard:
    temp1=""
    temp2=""
    temp3=""
    for i in range(0,wildindex):
        temp1 += parse2[i]
    for j in range(0,wildindex):
        temp2 += parse3[j]
    for k in range(wildindex,len(parse3)):
        temp3 += parse3[k]
    temp4=parse2[n-1]
    temp5=parse3[m-1]
    if n <= m:
        if temp1 == temp2 and temp4 == temp5:
            print('Yes')
        else:
            print('No')
    else:
        temp6=s.replace("*","")
        if temp6 == t:
            print('Yes')
        else:
            print('No')
else:
    if s == t:
        print("Yes")
    else:
        print("No")


#Stanley Tantysco - 2201814670
#Problem B - Wild Card

def str_limit(n):
    if (n >= 1 and n <= 200000):
        return True
    else:
        return False

def wild_counter(s):
    count=0
    for i in s:
        if i == '*':
            count += 1
    if count <= 1:
        return True
    else:
        return False

limit_in=input()
parse=limit_in.split(' ')
n=int(parse[0])
m=int(parse[1])

s=input()
t=input()

parse2=list(s)
parse3=list(t)
#print(parse2)
#print(parse3)

wildcard=False
wildindex=-1
firststr=""
laststr=""
for i in range(0,len(parse2)):
    if parse2[i]=='*':
        wildcard=True
        wildindex=i
        firststr=s[:wildindex]
        laststr=s[wildindex+1:len(parse2)]
        break

if wildcard:
    if n <= m:
        if len(s) != 1:
            if s[0] == '*':
                temp1=t[:(len(t)+1)-len(s)]
                temp3=temp1+laststr
            elif s[len(parse2)-1] == '*':
                temp1=t[len(s)-1:len(t)]
                temp3=firststr+temp1
            else:
                temp1=t.replace(laststr,"")
                temp2=temp1.replace(firststr,"")
                temp3=firststr+temp2+laststr
        else:
            temp3=s.replace('*',t)
        if temp3 == t:
            print('Yes')
        else:
            print('No')
    else:
        temp2=s.replace("*","")
        if temp2 == t:
            print('Yes')
        else:
            print('No')
else:
    if s == t:
        print("Yes")
    else:
        print("No")


#Stanley Tantysco - 2201814670
#Problem B - Wild Card

def str_limit(n):
    if (n >= 1 and n <= 200000):
        return True
    else:
        return False

def wild_counter(s):
    count=0
    for i in s:
        if i == '*':
            count += 1
    if count <= 1:
        return True
    else:
        return False

limit_in=input()
parse=limit_in.split(' ')
n=int(parse[0])
m=int(parse[1])

s=input()
t=input()

parse2=list(s)
parse3=list(t)
#print(parse2)
#print(parse3)

wildcard=False
wildindex=-1
for i in range(0,len(parse2)):
    if parse2[i]=='*':
        wildcard=True
        wildindex=i
        break

if wildcard:
    temp1=""
    if n == m:
        for i in range(0,len(parse2)):
            if parse2[i] == '*':
                parse2[i] = parse3[i]
                temp1 += parse2[i]
    else:
        if len(parse2) != 1:
            for j in range(wildindex,len(parse3)-1):
                temp1 += parse3[j]
        else:
            for j in range(wildindex,len(parse3)):
                temp1 += parse3[j]
    temp3=s.replace('*',temp1)
    if n <= m:
        if temp3 == t:
            print('Yes')
        else:
            print('No')
    else:
        temp2=s.replace("*","")
        if temp2 == t:
            print('Yes')
        else:
            print('No')
else:
    if s == t:
        print("Yes")
    else:
        print("No")


#Stanley Tantysco - 2201814670
#Problem B - Wild Card

def str_limit(n):
    if (n >= 1 and n <= 200000):
        return True
    else:
        return False

def wild_counter(s):
    count=0
    for i in s:
        if i == '*':
            count += 1
    if count <= 1:
        return True
    else:
        return False

limit_in=input()
parse=limit_in.split(' ')
n=int(parse[0])
m=int(parse[1])

s=input()
t=input()

parse2=list(s)
parse3=list(t)
#print(parse2)
#print(parse3)

wildcard=False
wildindex=-1
firststr=""
laststr=""
for i in range(0,len(parse2)):
    if parse2[i]=='*':
        wildcard=True
        wildindex=i
        firststr=s[:wildindex]
        laststr=s[wildindex+1:len(parse2)]
        break

if wildcard:
    if n <= m:
        #temp1=t.replace(laststr,"")
        #temp2=temp1.replace(firststr,"")
        if s[0] == '*':
            temp1=t.replace(laststr,"")
            temp3=temp1+laststr
        elif s[len(parse2)-1] == '*':
            temp1=t.replace(firststr,"")
            temp3=firststr+temp1
        else:
            temp1=t.replace(laststr,"")
            temp2=temp1.replace(firststr,"")
            temp3=firststr+temp2+laststr
        if temp3 == t:
            print('Yes')
        else:
            print('No')
    else:
        temp2=s.replace("*","")
        if temp2 == t:
            print('Yes')
        else:
            print('No')
else:
    if s == t:
        print("Yes")
    else:
        print("No")


#Stanley Tantysco - 2201814670
#Problem B - Wild Card

def str_limit(n):
    if (n >= 1 and n <= 200000):
        return True
    else:
        return False

def wild_counter(s):
    count=0
    for i in s:
        if i == '*':
            count += 1
    if count <= 1:
        return True
    else:
        return False

limit_in=input()
parse=limit_in.split(' ')
n=int(parse[0])
m=int(parse[1])

s=input()
t=input()

parse2=list(s)
parse3=list(t)
#print(parse2)
#print(parse3)

wildcard=False
wildindex=-1
firststr=""
laststr=""
for i in range(0,len(parse2)):
    if parse2[i]=='*':
        wildcard=True
        wildindex=i
        firststr=s[:wildindex]
        laststr=s[wildindex+1:len(parse2)]
        break

if wildcard:
    if n <= m:
        if len(s) != 1:
            if s[0] == '*':
                temp1=t[:len(t)-1]
                temp3=temp1+laststr
            elif s[len(parse2)-1] == '*':
                temp1=t[1:len(t)]
                temp3=firststr+temp1
            else:
                temp1=t.replace(laststr,"")
                temp2=temp1.replace(firststr,"")
                temp3=firststr+temp2+laststr
        else:
            temp3=s.replace('*',t)
        if temp3 == t:
            print('Yes')
        else:
            print('No')
    else:
        temp2=s.replace("*","")
        if temp2 == t:
            print('Yes')
        else:
            print('No')
else:
    if s == t:
        print("Yes")
    else:
        print("No")


#Stanley Tantysco - 2201814670
#Problem B - Wild Card

def str_limit(n):
    if (n >= 1 and n <= 200000):
        return True
    else:
        return False

def wild_counter(s):
    count=0
    for i in s:
        if i == '*':
            count += 1
    if count <= 1:
        return True
    else:
        return False

limit_in=input()
parse=limit_in.split(' ')
n=int(parse[0])
m=int(parse[1])

s=input()
t=input()

parse2=list(s)
parse3=list(t)
#print(parse2)
#print(parse3)

wildcard=False
wildindex=-1
for i in range(0,len(parse2)):
    if parse2[i]=='*':
        wildcard=True
        wildindex=i
        break

if wildcard:
    temp1=""
    if n == m:
        for i in range(0,len(parse2)):
            if parse2[i] == '*':
                parse2[i] = parse3[i]
                temp1 += parse2[i]
    else:
        if len(parse2) != 1:
            for i in range(wildindex,len(parse2)):
                temp2=s.replace(parse2[i],"")
            #print(temp2)
            for j in range(wildindex,len(parse3)):
                temp1 += parse3[j]
            temp3=temp2.replace('*',temp1)
        else:
            for j in range(wildindex,len(parse3)):
                temp1 += parse3[j]
            temp3=s.replace('*',temp1)
    if n <= m:
        if temp3 == t:
            print('Yes')
        else:
            print('No')
    else:
        temp2=s.replace("*","")
        if temp2 == t:
            print('Yes')
        else:
            print('No')
else:
    if s == t:
        print("Yes")
    else:
        print("No")


#Stanley Tantysco - 2201814670
#Problem B - Wild Card

def str_limit(n):
    if (n >= 1 and n <= 200000):
        return True
    else:
        return False

def wild_counter(s):
    count=0
    for i in s:
        if i == '*':
            count += 1
    if count <= 1:
        return True
    else:
        return False

limit_in=input()
parse=limit_in.split(' ')
n=int(parse[0])
m=int(parse[1])

s=input()
t=input()

parse2=list(s)
parse3=list(t)
#print(parse2)
#print(parse3)
if n == m:
    if '*' not in parse2:
        if s == t:
            print('Yes')
        else:
            print('No')
    else:
        print('No')
elif n > m:
    temp = ""
    parse2.remove('*')
    for i in parse2:
        temp += i
    #print(temp)
    if temp == t:
        print('Yes')
    else:
        print('No')
else:
    index=-1
    for i in range(0,len(parse2)):
        if parse2[i] == '*':
           index=i
           break
    x = slice(index)

    temp1 = ""
    for i in range(0,index):
        temp1 += parse2[i]

    temp2= ""
    for j in range(0,index):
        temp2 += parse3[j]

    if temp1 == temp2:
        print('Yes')
    else:
        print('No')


#Stanley Tantysco - 2201814670
#Problem B - Wild Card

def str_limit(n):
    if (n >= 1 and n <= 200000):
        return True
    else:
        return False

def wild_counter(s):
    count=0
    for i in s:
        if i == '*':
            count += 1
    if count <= 1:
        return True
    else:
        return False

limit_in=input()
parse=limit_in.split(' ')
n=int(parse[0])
m=int(parse[1])

s=input()
t=input()

parse2=list(s)
parse3=list(t)
#print(parse2)
#print(parse3)

wildcard=False
wildindex=-1
firststr=""
laststr=""
for i in range(0,len(parse2)):
    if parse2[i]=='*':
        wildcard=True
        wildindex=i
        firststr=s[:wildindex]
        laststr=s[wildindex+1:len(parse2)]
        break

if wildcard:
    if n <= m:
        temp1=t.replace(laststr,"")
        temp2=temp1.replace(firststr,"")
        if s[0] == '*':
            temp3=temp2+laststr
        elif s[len(parse2)-1] == '*':
            temp3=firststr+temp2
        else:
            temp3=firststr+temp2+laststr
        if temp3 == t:
            print('Yes')
        else:
            print('No')
    else:
        temp2=s.replace("*","")
        if temp2 == t:
            print('Yes')
        else:
            print('No')
else:
    if s == t:
        print("Yes")
    else:
        print("No")


n,m=map(int,input().split())
s=input()
t=input()
k=0
j=0
if(s.count("*")==0 ):
    if(t==s):
        print("YES")
    else:
        print("NO")
else:
    k=s.find("*")
    l=s[k+1:]
    if(t[:k]==s[:k] and t[::-1].find(l[::-1])==0):
        print("YES")
    else:
        print("NO")


n,m=map(int,input().split())
s=input()
t=input()
k=0
j=0
if(s.count("*")==0 ):
    if(t==s):
        print("YES")
    else:
        print("NO")
else:
    k=s.find("*")
    l=s[k+1:]
    q=t[k+1:]
    if(t[:k]==s[:k] and q[::-1].find(l[::-1])==0):
        print("YES")
    else:
        print("NO")


n,m=map(int,input().split())
s=input()
t=input()
k=0
j=0
if(s.count("*")==0 ):
    if(t==s):
        print("YES")
    else:
        print("NO")
else:
    k=s.find("*")
    if(t.find(s[:k])!=-1 and t[s.find("*"):].find(s[k+1:])!=-1 and t[s.find("*")::-1].find(s[k+1::-1])==0):
        print("YES")
    else:
        print("NO")


n,m=map(int,input().split())
s=input()
t=input()
k=0
j=0
if(s.count("*")==0 ):
    if(t.find(s)!=-1):
        print("YES")
    else:
        print("NO")
else:
    k=s.find("*")
    if(t.find(s[:k])!=-1 and t[s.find("*"):].find(s[k+1:])!=-1):
        print("YES")
    else:
        print("NO")


n,m=map(int,input().split())
s=input()
t=input()
k=0
j=0
if(s.count("*")==0 ):
    if(t==s):
        print("YES")
    else:
        print("NO")
else:
    k=s.find("*")
    if(t.find(s[:k])!=-1 and t[s.find("*"):].find(s[k+1:])!=-1 and t[s.find("*")::-1].find(s[k+1:])==0):
        print("YES")
    else:
        print("NO")


n,m=map(int,input().split())
s=input()
t=input()
k=0
j=0
if(s.count("*")==0 ):
    if(t==s):
        print("YES")
    else:
        print("NO")
else:
    k=s.find("*")
    l=s[k+1:]
    q=t[k:]
    if(t[:k]==s[:k] and q[::-1].find(l[::-1])==0):
        print("YES")
    else:
        print("NO")


n,m=map(int,input().split())
s=input()
t=input()
k=0
j=0
c=s.count("*");
for i in range(c):
    a=s.find("*");
    if(t[k:].find(s[k:a])==-1):
        j=1
        break
    k=a
if(t[k:].find(s[k:])==-1):
    j=1
if(j==0):
    print("YES")
else:
    print("NO")


n,m=map(int,input().split())
s=input()
t=input()
k=0
j=0
if(s.count("*")==0 ):
    if(t.find(s)!=-1):
        print("YES")
    else:
        print("NO")
else:
    k=s.find("*")
    if(t.find(s[:k])!=-1 and t[t.find(s[:k]):].find(s[k+1:])!=-1):
        print("YES")
    else:
        print("NO")


n,m=map(int,input().split())
s=input()
t=input()
k=0
j=0
if(s.count("*")==0 ):
    if(t==s):
        print("YES")
    else:
        print("NO")
else:
    k=s.find("*")
    l=s[k+1:]
    if(t[:k]==s[:k] and t[::-1].find(l)==0):
        print("YES")
    else:
        print("NO")


def get_problem_data():
    global p, m, k,g
    M = lambda: list(map(int, input().split()))
    n, k = M()
    p = input()
    g = input()

def solve(p,c):
    b = p.split("*")
    ss = True
    for i in b:
        if i not in c:
            ss = False
    if b[0] in c and len(p)-p.count("*") <= len(c) and "*" in p and ss:
        return "YES"
    else:
        return "NO"

get_problem_data()
print(solve(p, g))


def get_problem_data():
    global p, m, k,g
    M = lambda: list(map(int, input().split()))
    n, k = M()
    p = input()
    g = input()

def solve(p,c):
    b = p.split("*")
    ss = True
    for i in b:
        if i not in c:
            ss = False
    tt=True
    for i in c:
        if not i.isalpha():
            tt=False
    if b[0] in c and len(p)-p.count("*") <= len(c) and "*" in p and ss and tt:
        return "YES"
    else:
        return "NO"

get_problem_data()
print(solve(p, g))


def get_problem_data():
    global p, m, k,g
    M = lambda: list(map(int, input().split()))
    n, k = M()
    p = input()
    g = input()

def solve(p,c):
    b = p.split("*")
    ss = True
    for i in b:
        if i not in c:
            ss = False
    tt=True
    for i in c:
        if not i.isalpha():
            tt=False
    if len(p)-p.count("*") <= len(c) and "*" in p and ss and tt:
        return "YES"
    else:
        return "NO"

get_problem_data()
print(solve(p, g))


def get_problem_data():
    global n, m, s, t
    M = lambda: list(map(int, input().split()))
    n, m = M()
    s = input()
    t = input()

def solve(n, m, s, t):
    if '*' in s:
        l, r = s.split('*')
        return len(l) + len(r) <= len(t) and t.startswith(l) and t.endswith(r)
    else:
        return s == t

get_problem_data()
print(['NO', 'YES'][solve(n, m, s, t)])


def get_problem_data():
    global p, m, k,g
    M = lambda: list(map(int, input().split()))
    n, k = M()
    p = input()
    g = input()

def solve(p,c):
    b = p.split("*")
    if b[0] in c and len(p)-p.count("*") <= len(c) and "*" in p:
        return "YES"
    else:
        return "NO"

get_problem_data()
print(solve(p, g))


n,m=map(int,input().split())
x=input()
y=input()
'''for i in range(len(x)):
	if x[i]!='*':
		a.append(x[i])
	else:
		c+=1
		break
for j in range(i+1,n):
	b.append(x[j])
if c==0:
	f=1
	if n!=m:
		f=0
	else:
		for i in range(n):
			if x[i]!=y[i]:
				f=0
				break
	if f==0:
		print("NO")
	else:
		print("YES")
else:'''

i=0
j=len(x)-1
k=len(y)-1
flag=0
while(x[i]!='*'):
	if(x[i]!=y[i]):
		#print(x[i],y[i])
		flag=1
		break
	i+=1

while(x[j]!='*'):
	if(k<i):
		flag=1
		break
	if(x[j]!=y[k]):
		#print(x[j],y[k])

		flag=1
		break

	j-=1
	k-=1

if(flag==0):
	print("YES")

else:
	print("NO")


n,m=map(int,input().split())
x=input()
y=input()
a=[]
b=[]
c=0
for i in range(len(x)):
	if x[i]!='*':
		a.append(x[i])
	else:
		c+=1
		break
for j in range(i+1,n):
	b.append(x[j])
if c==0:
	f=1
	if n!=m:
		f=0
	else:
		for i in range(n):
			if x[i]!=y[i]:
				f=0
				break
	if f==0:
		print("NO")
	else:
		print("YES")
else:
	i=0
	j=len(x)-1
	k=len(y)-1
	flag=0
	while(x[i]!='*'):
		if(x[i]!=y[i]):
		#print(x[i],y[i])
			flag=1
			break
		i+=1

	while(x[j]!='*'):
		if(k<i):
			flag=1
			break
		if(x[j]!=y[k]):
		#print(x[j],y[k])

			flag=1
			break
		j-=1
		k-=1

	if(flag==0):
		print("YES")
	else:
		print("NO")


n,m=map(int,input().split())
x=input()
y=input()
a=[]
b=[]
c=0
for i in range(len(x)):
	if x[i]!='*':
		a.append(x[i])
	else:
		c+=1
		break
for j in range(i+1,n):
	b.append(x[j])
if c==0:
	f=1
	if n!=m:
		f=0
	else:
		for i in range(n):
			if x[i]!=y[i]:
				f=0
				break
	if f==0:
		print("NO")
	else:
		print("YES")
else:
	vis=[0]*(m)
	flag=1
	for i in range(len(a)):
		if a[i]!=y[i]:
			flag=0
			break
	for i in range(len(a)):
		vis[i]=1
	b=b[::-1]
	vis=vis[::-1]
	y=y[::-1]
	for i in range(len(b)):
		if vis[i]==1:
			flag=0
			break
		if b[i]!=y[i]:
			flag=0
			break
	# print(vis)
	# print(b)
	# print(y)
	if flag==0:
		print("NO")
	else:
		print("YES")


n,m=map(int,input().split())
x=input()
y=input()
a=[]
b=[]
c=0
for i in range(len(x)):
	if x[i]!='*':
		a.append(x[i])
	else:
		c+=1
		break
for j in range(i+1,n):
	b.append(x[j])
if c==0:
	f=1
	if n!=m:
		f=0
	else:
		for i in range(n):
			if x[i]!=y[i]:
				f=0
				break
	if f==0:
		print("NO")
	else:
		print("YES")
else:
	if (len(x)-1)>len(y):
		print("NO")
	else:
		i=x.index('*')
		a=x[0:i]
		b=y[0:i]
		c=x[i+1:]
		d=y[len(y)-(len(x)-i-1):]
		# print(a)
		# print(b)
		# print(c)
		# print(d)
		if a==b and c==d:
			print("YES")
		else:
			print("NO")


n,m=map(int,input().split())
s=input()
t=input()
l=[-1]
ans=[]
for i in range(n):
    if s[i]=="*":
        l.append(i)
a=max(l)
if max(l)==-1:
    if s==t:
        ans.append("YES")
    else:
        ans.append("NO")
else:
    if s[:a] != t[:a]:
        ans.append("NO")
    else:
        if n<=m:
            p=s[n:a:-1]
            x=len(p)
            if t[m:m-x-1:-1]==p:
                ans.append("YES")
            else:
                ans.append("NO")
        else:
            ans.append("NO")
print(*ans)


n,m=map(int,input().split())
s=input()
t=input()
l=[-1]
ans=[]
for i in range(n):
    if s[i]=="*":
        l.append(i)
a=max(l)
if max(l)==-1:
    if s==t:
        ans.append("YES")
    else:
        ans.append("NO")
else:
    if s[:a] != t[:a]:
        ans.append("NO")
    else:
        if n<=m:
            print("uidshfi")
            p=s[n:a:-1]
            x=len(p)
            if t[m:m-x-1:-1]==p:
                ans.append("YES")
            else:
                ans.append("NO")
        else:
            ans.append("NO")
print(*ans)


n,m=map(int,input().split())
s=input()
t=input()
l=[-1]
ans=[]
for i in range(n):
    if s[i]=="*":
        l.append(i)
a=max(l)
if max(l)==-1:
    if s==t:
        ans.append("YES")
    else:
        ans.append("NO")
else:
    if n-a-1<=m-a:
        if s[:a] != t[:a]:
            ans.append("NO")
        else:
            p=s[n:a:-1]
            x=len(p)
            yu=t[m:m-x-1:-1]
            if len(t[m:m-x-1:-1])==0 and a==0:
                yu=t
            if yu==p:
                ans.append("YES")
            else:
                ans.append("NO")
    else:
        ans.append("NO")
print(*ans)


n,m=map(int,input().split())
s=input()
t=input()
l=[-1]
ans=[]
for i in range(n):
    if s[i]=="*":
        l.append(i)
a=max(l)
if max(l)==-1:
    if s==t:
        ans.append("YES")
    else:
        ans.append("NO")
else:
    if n-a-1<=m-a:
        if s[:a] != t[:a]:
            ans.append("NO")
        else:
            p=s[n:a:-1]
            x=len(p)
            if t[m:m-x-1:-1]==p:
                ans.append("YES")
            else:
                ans.append("NO")
    else:
        ans.append("NO")
print(*ans)


import sys
n,m=map(int,input().split())
s=input()
t=input()
l=[-1]
ans=[]
for i in range(n):
    if s[i]=="*":
        l.append(i)
a=max(l)
if max(l)==-1:
    if s==t:
        ans.append("YES")
    else:
        ans.append("NO")
else:
    if n-a-1<=m-a:
        if s[:a] != t[:a]:
            ans.append("NO")
        else:
            p=s[n:a:-1]
            x=len(p)
            if x==0:
                ans.append("YES")
                print(*ans)
                sys.exit()
            yu=t[m:m-x-1:-1]
            if len(t[m:m-x-1:-1])==0 and a==0:
                yu=t
            if yu==p:
                ans.append("YES")
            else:
                ans.append("NO")
    else:
        ans.append("NO")
print(*ans)


n, m = map(int, input().split())
s = input()
t = input()
if(m < n-1):
    print("NO")
elif s == "*":
    print("YES")
else:
    if(s.find("*") == -1):
        if(s != t):
            print("NO")
        else:
            print("YES")
    else:
        st, dr = s.split("*")
        tc = t
        t = t.replace(st, "", 1)
        t = t[len(t)::-1]
        dr = dr[len(dr)::-1]
        t = t.replace(dr, "", 1)
        t = t[len(t)::-1]
        if(s.replace("*", t) == tc):
            print("YES")
        else:
            print("NO")


n, m = map(int, input().split())
s = input()
t = input()
if(m < n-1):
    print("NO")
elif s == "*":
    print("YES")
else:
    if(s.find("*") == -1):
        if(s != t):
            print("NO")
        else:
            print("YES")
    else:
        st, dr = s.split("*")
        if(t.find(st) != 0):
            print("NO")
        else:
            t.replace(st, "")
            poz = t.find(dr)
            if(t[poz:] != dr):
                print("NO")
            else:
                print("YES")


n, m = map(int, input().split())
s = input()
t = input()
if(m < n-1):
    print("NO")
else:
    if(s.find("*") == -1):
        if(s != t):
            print("NO")
        else:
            print("YES")
    else:
        st, dr = s.split("*")
        p1 = t.find(st)
        p2 = t.find(dr)
        if(p1 >= p2):
            print("NO")
        else:
            print("YES")


n, m = map(int, input().split())
s = input()
t = input()
if(m < n-1):
    print("NO")
elif s == "*":
    print("YES")
else:
    if(s.find("*") == -1):
        if(s != t):
            print("NO")
        else:
            print("YES")
    else:
        st, dr = s.split("*")
        tc = t
        t = t.replace(st, "", 1)
        t = t[len(t)::-1]
        t = t.replace(dr, "", 1)
        t = t[len(t)::-1]
        if(s.replace("*", t) == tc):
            print("YES")
        else:
            print("NO")


n, m = map(int, input().split())
s = input()
t = input()
if(m < n-1):
    print("NO")
elif s == "*":
    print("YES")
else:
    if(s.find("*") == -1):
        if(s != t):
            print("NO")
        else:
            print("YES")
    else:
        st, dr = s.split("*")
        tc = t
        t = t.replace(st, "", 1)
        t = t.replace(dr, "", 1)
        if(s.replace("*", t) == tc):
            print("YES")
        else:
            print("NO")


n, m = map(int, input().split())
s = input()
t = input()
if(m < n-1):
    print("NO")
else:
    if(s.find("*") == -1):
        if(s != t):
            print("NO")
        else:
            print("YES")
    else:
        st, dr = s.split("*")
        if(t.find(st) != 0):
            print("NO")
        else:
            t.replace(st, "")
            poz = t.find(dr)
            if(t[poz:] != dr):
                print("NO")
            else:
                print("YES")


#https://codeforces.com/problemset/problem/1023/A
x, y = input().split()
n, m = int(x), int(y)
s = input()
t = input()

if '*' not in s and s != t:
    print("NO")
elif '*' not in s and s==t:
    print("YES")
elif len(s) > len(t):
    print("NO")
else:
    ok = True
    i = 0
    while s[i] != '*':
        if s[i] != t[i]:
            print("NO")
            ok = False
            break
        i += 1
    #print(s[i+1:],"----",t[i+ 1-len(s):])
    if s[i+1:] != t[i + 1-len(s):]:
        ok = False
        print("NO")
    if ok:
        print("YES")


#https://codeforces.com/problemset/problem/1023/A
x, y = input().split()
n, m = int(x), int(y)
s = input()
t = input()

if '*' not in s and s != t:
    print("NO")
elif '*' not in s and s==t:
    print("YES")
elif len(s) > len(t) + 1:
    print("NO")
elif s == "*":
    print("YES")
else:
    ok = True
    i = 0
    while s[i] != '*':
        if s[i] != t[i]:
            print("NO")
            ok = False
            break
        i += 1
    j,k=len(t)-1,len(s)-1
    while s[k] != '*':
        if s[k] != t[j]:
            ok = False
            print("NO")
            break
        k -= 1
        j -= 1
    if ok:
        print("YES")


#https://codeforces.com/problemset/problem/1023/A
x, y = input().split()
n, m = int(x), int(y)
s = input()
t = input()

if '*' not in s and s != t:
    print("NO")
elif '*' not in s and s==t:
    print("YES")
elif len(s) > len(t) + 1:
    print("NO")
elif s == "*":
    print("YES")
else:
    ok = True
    i = 0
    while s[i] != '*':
        if s[i] != t[i]:
            print("NO")
            ok = False
            break
        i += 1
    j,k=len(t)-1,len(s)-1
    while s[k] != '*' and ok:
        if s[k] != t[j]:
            ok = False
            print("NO")
            break
        k -= 1
        j -= 1
    if ok:
        print("YES")


#https://codeforces.com/problemset/problem/1023/A
x, y = input().split()
n, m = int(x), int(y)
s = input()
t = input()

if '*' not in s and s != t:
    print("NO")
elif '*' not in s and s==t:
    print("YES")
elif len(s) > len(t) + 1:
    print("NO")
else:
    ok = True
    i = 0
    while s[i] != '*':
        if s[i] != t[i]:
            print("NO")
            ok = False
            break
        i += 1
    #print(s[i+1:],"----",t[i+ 1-len(s):])
    if s[i+1:] != t[i + 1-len(s):]:

        print("NO")
        ok = False
    if ok:
        print("YES")


#include <bits\stdc++.h>
using namespace std;
#define all(v) begin(v),end(v)
#define rall(v) rbegin(v),rend(v)
using ld = long double;
using ll = long long;
using pll = pair<ll, ll>;
//-----------------------------

void solve() //----------------
{
	ll n, d, pr, r = 0;
	cin >> n >> d >> pr; n--;
	while (n--) {
		ll t; cin >> t;
		ll k = ceil(ld(pr - t + 1) / d);
		if (k > 0) r += k;
		pr = t + k * d;
	}
	cout << r;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr); cout.tie(nullptr);
#ifdef LocaL
	freopen("input.txt", "r+", stdin);
	freopen("output.txt", "w+", stdout);
#endif
	solve();
	return 0;
}


#include <bits\stdc++.h>
using namespace std;
#define all(v) begin(v),end(v)
#define rall(v) rbegin(v),rend(v)
using ld = long double;
using ll = long long;
using pll = pair<ll, ll>;
//-----------------------------

void solve() //----------------
{
	ll n, d, pr, r = 0;
	cin >> n >> d >> pr; n--;
	while (n--) {
		ll t; cin >> t;
		ll k = ceil(ld(pr - t + 1) / d);
		if (k > 0) {
			r += k;
			k = 0;
		}
		pr = t + k * d;
	}
	cout << r;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr); cout.tie(nullptr);
#ifdef LocaL
	freopen("input.txt", "r+", stdin);
	freopen("output.txt", "w+", stdout);
#endif
	solve();
	return 0;
}


#include <bits\stdc++.h>
using namespace std;
#define all(v) begin(v),end(v)
#define rall(v) rbegin(v),rend(v)
using ld = long double;
using ll = long long;
using pll = pair<ll, ll>;
//-----------------------------

void solve() //----------------
{
	ll n, d, pr, r = 0;
	cin >> n >> d >> pr; n--;
	while (n--) {
		ll t; cin >> t;
		ll k = ceil(ld(pr - t + 1) / d);
		if (k > 0) r += k;
		else k = 0;
		pr = t + k * d;
	}
	cout << r;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr); cout.tie(nullptr);
#ifdef LocaL
	freopen("input.txt", "r+", stdin);
	freopen("output.txt", "w+", stdout);
#endif
	solve();
	return 0;
}


// Problem : A. Increasing Sequence
// Contest : Codeforces - Codeforces Beta Round #11
// URL : https://codeforces.com/problemset/problem/11/A
// Memory Limit : 64 MB
// Time Limit : 1000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=1;i<=(int)n;i++)
#define REP(i,n) for(int i=0;i<(int)n;i++)
#define ll long long
#define mod 1000000007
int lcm(int x,int y){
	return x/__gcd(x,y)*y;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    int d;
    cin>>n>>d;
    int arr[n];
    int ans=0;
    int t=0;
    for(int i=1;i<=n;i++){
    cin>>arr[i];
    if(arr[i-1]>=arr[i]){
    	t=(arr[i-1]-arr[i])/d+1;
    	ans+=t;
    	arr[i]+=t*d;
    }
}
	cout<<ans<<endl;
    return 0;
}


// Problem : A. Increasing Sequence
// Contest : Codeforces - Codeforces Beta Round #11
// URL : https://codeforces.com/problemset/problem/11/A
// Memory Limit : 64 MB
// Time Limit : 1000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=1;i<=(int)n;i++)
#define REP(i,n) for(int i=0;i<(int)n;i++)
#define ll long long
#define mod 1000000007
int lcm(int x,int y){
	return x/__gcd(x,y)*y;
}
int arr[2001];
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    int d;
    cin>>n>>d;
    int ans=0;
    int t=0;
    for(int i=1;i<=n;i++){
    cin>>arr[i];
    if(arr[i-1]>=arr[i]){
    	t=(arr[i-1]-arr[i])/d+1;
    	ans+=t;
    	arr[i]+=t*d;
    }
}
	cout<<ans<<endl;
    return 0;
}


// Problem : A. Increasing Sequence
// Contest : Codeforces - Codeforces Beta Round #11
// URL : https://codeforces.com/problemset/problem/11/A
// Memory Limit : 64 MB
// Time Limit : 1000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=1;i<=(int)n;i++)
#define REP(i,n) for(int i=0;i<(int)n;i++)
#define ll long long
#define mod 1000000007
int lcm(int x,int y){
	return x/__gcd(x,y)*y;
}
int arr[2001];
int n,d;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
	cin>>n>>d;
	int t=0;
	int ans=0;
	for(int i=1;i<=n;i++){
	cin>>arr[i];
	if(arr[i]<=arr[i-1]){
			t=(arr[i-1]-arr[i])/d+1;
			ans+=t;
			arr[i]+=t*d;
		}
	}
	cout<<ans<<endl;
    return 0;
}


// Problem : A. Increasing Sequence
// Contest : Codeforces - Codeforces Beta Round #11
// URL : https://codeforces.com/problemset/problem/11/A
// Memory Limit : 64 MB
// Time Limit : 1000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=1;i<=(int)n;i++)
#define REP(i,n) for(int i=0;i<(int)n;i++)
#define ll long long
#define mod 1000000007
int lcm(int x,int y){
	return x/__gcd(x,y)*y;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    int arr[n];
    int d;
    cin>>d;
    for(int i=0;i<n;i++){
	cin>>arr[i];
    }
    sort(arr,arr+n);
    int cnt=0;
    for(int i=0;i<n;i++){
    	if(arr[i]!=arr[i+1]){
		cnt++;
    	}
    }

    cout<<cnt<<endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int count()
{

}
int main()
{
	int n;int c=0;
	int diff=0;
	int k=0;
	long d;
	cin>>n>>d;
	int a[n];
	for(int i=0;i<n;i++)
	cin>>a[i];
	for(int i=0;i<n-1;i++)
	{
		if(a[i]<a[i+1])
		continue;
		else
		{
		diff=a[i]-a[i+1];
		if (diff==0)
		{
		a[i+1]=a[i+1]+d;
		c=c+1;
	}

		else if(diff%d==0)
		{

		c=c+(diff/d);
		k=(diff/d);
		a[i+1]+=k*d;
	}

		else if(diff<d)
		{

		c=c+1;

		a[i+1]+=d;
	}
		else
		{

		c=c+(diff/d)+1;
		k=(diff/d)+1;
		a[i+1]+=k*d;
	}
		}

}
	cout<<c;

}


#include<bits/stdc++.h>
using namespace std;
int count()
{

}
int main()
{
	int n;int c=0;
	long d;
	cin>>n>>d;
	int a[n];
	for(int i=0;i<n;i++)
	cin>>a[i];
	for(int i=0;i<n;i++)
	{
		if(a[i]<a[i+1])
		continue;
		else
		{
			while(a[i]>=a[i+1])
			{
				a[i+1]+=d;
				c++;

			}
		}
	}
	cout<<c;

}


#include<bits/stdc++.h>
using namespace std;
int count()
{

}
int main()
{
	int n;
	int c=0;
	int diff=0;
	int k=0;
	long d;
	cin>>n>>d;
	int a[n];
	for(int i=0;i<n;i++)
	cin>>a[i];
	for(int i=0;i<n-1;i++)
	{
		if(a[i]<a[i+1])
		continue;
		else
		{
		diff=a[i]-a[i+1];
		if (diff==0)
		{
		a[i+1]+=d;
		c=c+1;
	}
		else if(diff<d)
		{

		c=c+1;

		a[i+1]+=d;
	}
		else
		{

		c=c+(diff/d)+1;
		k=(diff/d)+1;
		a[i+1]+=k*d;
	}
	k=0;
		}

}
	cout<<c;

}


#include<bits/stdc++.h>
using namespace std;
int count()
{

}
int main()
{
	int n;int c=0;
	int diff=0;
	long d;
	cin>>n>>d;
	int a[n];
	for(int i=0;i<n;i++)
	cin>>a[i];
	for(int i=0;i<n-1;i++)
	{
		if(a[i]<a[i+1])
		continue;
		else
		{
		diff=a[i]-a[i+1];
		if (diff==0)
		{
		a[i+1]=a[i+1]+d;
		c=c+1;
	}

		else if(diff%d==0)
		{

		c=c+(diff/d);
		a[i+1]+=c*d;
	}

		else if(diff<d)
		{

		c=c+1;
		a[i+1]+=d;
	}
		else
		{

		c=c+(diff/d)+1;
		a[i+1]+=c*d;
	}
		}

}
	cout<<c;

}


#include<bits/stdc++.h>
using namespace std;
int count()
{

}
int main()
{
	int n;int c=0;
	long d;
	cin>>n>>d;
	int a[n];
	for(int i=0;i<n;i++)
	cin>>a[i];
	for(int i=0;i<n-1;i++)
	{
		if(a[i]<a[i+1])
		continue;
		else
		{
			while(a[i]>=a[i+1])
			{
				a[i+1]+=d;
				c++;

			}
		}
	}
	cout<<c;

}


#include <bits/stdc++.h>
using namespace std;

const int N = 1e6 + 5;
int n[N];

int main(){
	int a, b, c = 0;
	cin >> a >> b;
	for (int i = 0; i < a; i++){
		cin >> n[i];
	}
	for (int i = 0; i < a - 1; i++){
		if (n[i] >= n[i + 1]){
			while (n[i] >= n[i + 1]){
				n[i + 1] += b;
				c++;
			}
		}
	}
	cout << c;
}


#include <bits/stdc++.h>
using namespace std;

const int N = 1e7 + 5;
long int n[N];

void get(){
	long int a, b, c = 0;
	cin >> a >> b;
	for (long int i = a - 1; i >= 0 ; i--){
		cin >> n[i];
		while (n[i] <= n[i + 1] && i != a - 1){
			n[i] += b;
			c++;
		}
	}
	cout << c;
}

int main() {
	get();
}


#include <bits/stdc++.h>
using namespace std;

const int N = 1e7 + 5;
int n[N];

long long int needed(int n[], int a, int b){
	long long int t = 0, x;
	for (int i = 1; i < a; i++){
		if (n[i] <= n[i - 1]){
			x = n[i - 1] - n[i];
			t += x / b + 1;
			n[i] += (x / b + 1) * b;
		}
	}
	return t;
}
int main() {
	int a, b;
	cin >> a >> b;
	for (int i = 0; i < a; i++){
		cin >> n[i];
	}
	cout << needed(n, a, b);
}


#include <bits/stdc++.h>
using namespace std;

const int N = 1e6 + 5;
int n[N];

int main(){
	int a, b, c = 0;
	cin >> a >> b;
	for (int i = 0; i < a; i++){
		cin >> n[i];
	}
	for (int i = 0; i < a - 1; i++){
		if (n[i] >= n[i + 1]){
			while (n[i] >= n[i + 1]){
				n[i + 1] += b * (n[i] / n[i + 1]);
				c += n[i + 1] / n[i + 1];
			}
		}
	}
	cout << c;
}


#include <bits/stdc++.h>
using namespace std;

const int N = 1e6 + 5;
long int n[N];

void get(){
	long int a, b, c = 0;
	cin >> a >> b;
	for (long int i = 0; i < a; i++){
		cin >> n[i];
		while (n[i] <= n[i - 1] && i != 0){
			n[i] += b;
			c++;
		}
	}
	cout << c;
}

int main() {
	get();
}


#include <bits/stdc++.h>
using namespace std;

const int N = 1e6 + 5;
int n[N];

int main(){
	int a, b, c = 0;
	cin >> a >> b;
	for (int i = 0; i < a; i++){
		cin >> n[i];
	}
	for (int i = 0; i < a - 1; i++){
		if (n[i] >= n[i + 1]){
			while (n[i] >= n[i + 1]){
				c += n[i] / n[i + 1];
				n[i + 1] += b * (n[i] / n[i + 1]);
			}
		}
	}
	cout << c;
}


#include <bits/stdc++.h>
using namespace std;

const int N = 1e5 + 5;
long int n[N];

void get(){
	int a, b, c = 0;
	cin >> a >> b;
	for (int i = 0; i < a; i++){
		cin >> n[i];
	}
	int i = 1;
	while (i < a){
		if (n[i] <= n[i - 1]){
			n[i] += b;
			c++;
		} else {
			i++;
		}
	}
	cout << c;
}

int main() {
	get();
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,d,c=0;
    cin>>n>>d;
    int a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    for(int i=1;i<n;i++)
    {
        while(a[i]<=a[i-1])
        {
            a[i]+=d;
            c++;
        }
    }
    cout<<c;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,d;
    cin>>n>>d;
    int a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    int ans=0;
    for(int i=1;i<n;i++)
    {
        int b=a[i-1]-a[i];
        if(a[i]<=a[i-1])
        {
            if(b%d==0)
            {
                a[i]=a[i-1]+d;
                ans+=b/d+1;
            }
            else
            {
                a[i]+=(b/d)*d+d;
                ans+=b/d+1;
            }
        }
    }
    cout<<ans;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,d,c=0;
    cin>>n>>d;
    int a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    for(int i=1;i<n;i++)
    {
        if(a[i]<=a[i-1])
        {
            int b=a[i-1]-a[i];
            if(a[i]==a[i-1])
            {
                c++;
                a[i]+=d;
            }
            if(b%d==0)
            {
                c+=b/d;
                a[i]+=b/d;
            }
            else
            {
                c+=b/d+1;
                a[i]+=b/d+1;
            }
        }
    }
    cout<<c;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,d;
    long long int c=0;
    cin>>n>>d;
    long long int a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    for(int i=1;i<n+1;i++)
    {
        if(a[i]<=a[i-1])
        {
            while(a[i-1]>=a[i])
            {
                a[i]+=d;
                c++;
            }
        }
    }
    cout<<c;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,d,c=0;
    cin>>n>>d;
    int a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    for(int i=1;i<n;i++)
    {
        if(a[i]<=a[i-1])
        {
            int b=a[i-1]-a[i];
            if(a[i]==a[i-1])
            {
                c++;
                a[i]+=d;
            }
            else if(b%d==0)
            {
                c+=b/d;
                a[i]+=b;
            }
            else
            {
                c+=b/d+1;
                a[i]+=b+1;
            }
        }
    }
    cout<<c;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,d,c=0;
    cin>>n>>d;
    int a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    for(int i=1;i<n;i++)
    {
        if(a[i]<=a[i-1])
        {
            int b=a[i-1]-a[i];
            if(b%d==0 and b/d==0)
                c+=d;
            if(b%d==0)
                c+=b/d;
            else
                c+=b/d+1;
        }
    }
    cout<<c;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,d;
    long long int c=0;
    cin>>n>>d;
    int a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    for(int i=1;i<n+1;i++)
    {
        if(a[i]<=a[i-1])
        {
            while(a[i-1]>=a[i])
            {
                a[i]+=d;
                c++;
            }
        }
    }
    cout<<c;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,d,c=0;
    cin>>n>>d;
    int a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    for(int i=1;i<n+1;i++)
    {
        if(a[i]<=a[i-1])
        {
            while(a[i-1]>=a[i])
            {
                a[i]+=d;
                c++;
            }
        }
    }
    cout<<c;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,d;
    cin>>n>>d;
    int a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    int ans=0;
    for(int i=1;i<n;i++)
    {
        int b=a[i-1]-a[i];
        if(a[i]<=a[i-1])
        {
            if(b%d==0)
            {
                a[i]=a[i-1]+d;
                ans+=b/d+1;
            }
            else
            {
                a[i]=(b/d)*d+d;
                ans+=b/d+1;
            }
        }
    }
    cout<<ans;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,d;
    cin>>n>>d;
    int a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    int ans=0;
    for(int i=1;i<n;i++)
    {
        int b=a[i-1]-a[i];
        if(a[i]<=a[i-1])
        {
            if(b%d==0)
            {
                a[i]=a[i-1]+d;
                ans+=b/d+d-1;
            }
            else
            {
                a[i]=(b/d)*d+d;
                ans+=b/d+1;
            }
        }
    }
    cout<<ans;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,d,c=0;
    cin>>n>>d;
    int a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    for(int i=1;i<n+1;i++)
    {
        if(a[i]<=a[i-1])
        {
            while(a[i-1]>=a[i])
            {
                a[i]+=d;
                c++;
            }
        }
    }
    cout<<c;
}


#include <bits/stdc++.h>
#define fr first
#define sc scanf
#define pf printf
#define se second
#define sq(x) x * x
#define ll long long
#define pb push_back
#define mk make_pair
#define ld long double
#define pr pair<int,int>
#define sz(s) int(s.size())
#define piip pair< pair<ll,ll>,ll >
#define fin(s) freopen( s, "r", stdin )
#define fout(s) freopen( s, "w", stdout )
#define TIME ios_base::sync_with_stdio(0)
using namespace std;

const ll INF = 1e9;
const ll N = 1e5;
const ll mod = 1e9 + 7;
const long double eps = 1E-7;
ll n , mx , mn = 1e9,cnt , m;
string s;
int main()
{
        TIME;
       cin >> n >> m;
       ll arr[ n ];
       for( int i = 0;i < n;i ++ )
        cin >> arr[i];
        for( int i = 1;i < n;i ++ ){
            if( arr[ i - 1 ] < arr[ i ] )
                continue;
            else
            {
                while( arr[ i - 1 ] >= arr[ i ] )
                    arr[ i ] += m;
                cnt ++;
            }
        }
        cout << cnt << endl;
        return 0;
}

/* MADE BY
//________________________________________________________
//________________________________________________________ //
                                                           //
// ██╗   ██╗     ██████╗     ███████╗    ██╗    ███╗   ██╗ //
// ╚██╗ ██╔╝    ██╔═══██╗    ██╔════╝    ██║    ████╗  ██║ //
//  ╚████╔╝     ██║   ██║    ███████╗    ██║    ██╔██╗ ██║ //
//   ╚██╔╝      ██║   ██║    ╚════██║    ██║    ██║╚██╗██║ //
//    ██║       ╚██████╔╝    ███████║    ██║    ██║ ╚████║ //
//    ╚═╝        ╚═════╝     ╚══════╝    ╚═╝    ╚═╝  ╚═══╝ //
//________________________________________________________ //
//________________________________________________________ */