public static void main ( String [ ] args ) throws Exception {
  FastReader fr = new FastReader ( ) ;
  int n = fr . nextInt ( ) ;
  int m = fr . nextInt ( ) ;
  String s = fr . next ( ) ;
  String t = fr . next ( ) ;
  boolean contains = false ;
  int idx = - 1 ;
  for ( int i = 0 ;
  i < s . length ( ) ;
  i ++ ) {
    if ( s . charAt ( i ) == '*' ) {
      contains = true ;
      idx = i ;
    }
  }
  if ( ! contains ) {
    if ( n != m || ! s . equals ( t ) ) System . out . println ( "NO" ) ;
    else System . out . println ( "YES" ) ;
  }
  else {
    if ( m < ( n - 1 ) ) System . out . println ( "NO" ) ;
    else {
      if ( m == n - 1 ) {
        int j = 0 ;
        boolean pos = true ;
        for ( int i = 0 ;
        i < s . length ( ) ;
        i ++ ) {
          if ( s . charAt ( i ) == '*' ) continue ;
          if ( s . charAt ( i ) != t . charAt ( j ) ) {
            pos = false ;
            break ;
          }
          j ++ ;
        }
        if ( pos ) System . out . println ( "YES" ) ;
        else System . out . println ( "NO" ) ;
      }
      else {
        boolean pos = true ;
        for ( int i = 0 ;
        i < idx ;
        i ++ ) {
          if ( s . charAt ( i ) != t . charAt ( i ) ) {
            pos = false ;
            break ;
          }
        }
        if ( pos == false ) System . out . println ( "NO" ) ;
        else {
          int j = m - 1 ;
          for ( int i = n - 1 ;
          i > idx ;
          i -- ) {
            if ( s . charAt ( i ) != t . charAt ( j ) ) {
              pos = false ;
              break ;
            }
            j -- ;
          }
          if ( pos == true ) System . out . println ( "YES" ) ;
          else System . out . println ( "NO" ) ;
        }
      }
    }
  }
}

public static void main ( String [ ] args ) throws Exception { FastReader fr = new FastReader ( ) ; int n = fr . nextInt ( ) ; int m = fr . nextInt ( ) ; String s = fr . next ( ) ; String t = fr . next ( ) ; boolean contains = false ; int idx = - 1 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( s . charAt ( i ) == ' * ' ) { contains = true ; idx = i ; } } if ( ! contains ) { if ( n != m || ! s . equals ( t ) ) System . out . println ( " NO " ) ; else System . out . println ( " YES " ) ; } else { if ( m < ( n - 1 ) ) System . out . println ( " NO " ) ; else { if ( m == n - 1 ) { int j = 0 ; boolean pos = true ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( s . charAt ( i ) == ' * ' ) continue ; if ( s . charAt ( i ) != t . charAt ( j ) ) { pos = false ; break ; } j ++ ; } if ( pos ) System . out . println ( " YES " ) ; else System . out . println ( " NO " ) ; } else { boolean pos = true ; for ( int i = 0 ; i < idx ; i ++ ) { if ( s . charAt ( i ) != t . charAt ( i ) ) { pos = false ; break ; } } if ( pos == false ) System . out . println ( " NO " ) ; else { int j = m - 1 ; for ( int i = n - 1 ; i > idx ; i -- ) { if ( s . charAt ( i ) != t . charAt ( j ) ) { pos = false ; break ; } j -- ; } if ( pos == true ) System . out . println ( " YES " ) ; else System . out . println ( " NO " ) ; } } } } }
(method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (array_type element: (type_identifier) dimensions: (dimensions)) name: (identifier))) (throws (type_identifier)) body: (block (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (type_identifier) arguments: (argument_list)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (local_variable_declaration type: (boolean_type) declarator: (variable_declarator name: (identifier) value: (false))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (unary_expression operand: (decimal_integer_literal)))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list))) update: (update_expression (identifier)) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))) right: (character_literal))) consequence: (block (expression_statement (assignment_expression left: (identifier) right: (true))) (expression_statement (assignment_expression left: (identifier) right: (identifier))))))) (if_statement condition: (parenthesized_expression (unary_expression operand: (identifier))) consequence: (block (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (identifier) right: (identifier)) right: (unary_expression operand: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier)))))) consequence: (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (string_literal)))) alternative: (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (string_literal)))))) alternative: (block (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))))) consequence: (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (string_literal)))) alternative: (block (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (binary_expression left: (identifier) right: (decimal_integer_literal)))) consequence: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (local_variable_declaration type: (boolean_type) declarator: (variable_declarator name: (identifier) value: (true))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list))) update: (update_expression (identifier)) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))) right: (character_literal))) consequence: (continue_statement)) (if_statement condition: (parenthesized_expression (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))))) consequence: (block (expression_statement (assignment_expression left: (identifier) right: (false))) (break_statement))) (expression_statement (update_expression (identifier))))) (if_statement condition: (parenthesized_expression (identifier)) consequence: (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (string_literal)))) alternative: (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (string_literal)))))) alternative: (block (local_variable_declaration type: (boolean_type) declarator: (variable_declarator name: (identifier) value: (true))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))))) consequence: (block (expression_statement (assignment_expression left: (identifier) right: (false))) (break_statement))))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (false))) consequence: (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (string_literal)))) alternative: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (identifier) right: (decimal_integer_literal)))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (identifier) right: (decimal_integer_literal)))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))))) consequence: (block (expression_statement (assignment_expression left: (identifier) right: (false))) (break_statement))) (expression_statement (update_expression (identifier))))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (true))) consequence: (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (string_literal)))) alternative: (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (string_literal)))))))))))))))