public static void main ( String [ ] args ) {
  Scanner sc = new Scanner ( System . in ) ;
  String po = sc . nextLine ( ) ;
  int n = sc . nextInt ( ) ;
  int count = 0 ;
  int x = 0 , y = 0 ;
  String s [ ] = po . split ( "" , 0 ) ;
  for ( int i = 0 ;
  i < s . length ;
  i ++ ) {
    if ( s [ i ] . equals ( "U" ) ) y -- ;
    else if ( s [ i ] . equals ( "D" ) ) y ++ ;
    else if ( s [ i ] . equals ( "R" ) ) x ++ ;
    else if ( s [ i ] . equals ( "L" ) ) x -- ;
    else count ++ ;
  }
  int h = Math . abs ( x ) + Math . abs ( y ) ;
  System . out . println ( ( n == 1 ) ? h + count : ( h < count ) ? ( ( h - count ) % 2 == 0 ) ? 0 : 1 : h - count ) ;
}

public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String po = sc . nextLine ( ) ; int n = sc . nextInt ( ) ; int count = 0 ; int x = 0 , y = 0 ; String s [ ] = po . split ( " " , 0 ) ; for ( int i = 0 ; i < s . length ; i ++ ) { if ( s [ i ] . equals ( " U " ) ) y -- ; else if ( s [ i ] . equals ( " D " ) ) y ++ ; else if ( s [ i ] . equals ( " R " ) ) x ++ ; else if ( s [ i ] . equals ( " L " ) ) x -- ; else count ++ ; } int h = Math . abs ( x ) + Math . abs ( y ) ; System . out . println ( ( n == 1 ) ? h + count : ( h < count ) ? ( ( h - count ) % 2 == 0 ) ? 0 : 1 : h - count ) ; }
(method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (array_type element: (type_identifier) dimensions: (dimensions)) name: (identifier))) body: (block (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (type_identifier) arguments: (argument_list (field_access object: (identifier) field: (identifier)))))) (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: (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: (decimal_integer_literal))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal)) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) dimensions: (dimensions) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (string_literal) (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: (field_access object: (identifier) field: (identifier))) update: (update_expression (identifier)) body: (block (if_statement condition: (parenthesized_expression (method_invocation object: (array_access array: (identifier) index: (identifier)) name: (identifier) arguments: (argument_list (string_literal)))) consequence: (expression_statement (update_expression (identifier))) alternative: (if_statement condition: (parenthesized_expression (method_invocation object: (array_access array: (identifier) index: (identifier)) name: (identifier) arguments: (argument_list (string_literal)))) consequence: (expression_statement (update_expression (identifier))) alternative: (if_statement condition: (parenthesized_expression (method_invocation object: (array_access array: (identifier) index: (identifier)) name: (identifier) arguments: (argument_list (string_literal)))) consequence: (expression_statement (update_expression (identifier))) alternative: (if_statement condition: (parenthesized_expression (method_invocation object: (array_access array: (identifier) index: (identifier)) name: (identifier) arguments: (argument_list (string_literal)))) consequence: (expression_statement (update_expression (identifier))) alternative: (expression_statement (update_expression (identifier))))))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier)))))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (ternary_expression condition: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) consequence: (binary_expression left: (identifier) right: (identifier)) alternative: (ternary_expression condition: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) consequence: (ternary_expression condition: (parenthesized_expression (binary_expression left: (binary_expression left: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) right: (decimal_integer_literal)) right: (decimal_integer_literal))) consequence: (decimal_integer_literal) alternative: (decimal_integer_literal)) alternative: (binary_expression left: (identifier) right: (identifier)))))))))