public static void main ( String [ ] args ) {
  MyScanner sc = new MyScanner ( ) ;
  out = new PrintWriter ( new BufferedOutputStream ( System . out ) ) ;
  int n = sc . nextInt ( ) ;
  int m = sc . nextInt ( ) ;
  int [ ] g = new int [ n ] ;
  for ( int i = 0 ;
  i < m ;
  ++ i ) {
    int x = sc . nextInt ( ) - 1 ;
    int y = sc . nextInt ( ) - 1 ;
    g [ x ] |= 1 << y ;
  }
  long [ ] dp = new long [ 1 << n ] ;
  dp [ 0 ] = 1 ;
  for ( int b = 1 ;
  b < 1 << n ;
  ++ b ) {
    for ( int i = 0 ;
    i < n ;
    ++ i ) {
      if ( ( b & 1 << i ) == 0 ) continue ;
      if ( ( ( b ^ 1 << i ) & g [ i ] ) == 0 ) dp [ b ] += dp [ b ^ 1 << i ] ;
    }
  }
  out . println ( dp [ ( 1 << n ) - 1 ] ) ;
  out . close ( ) ;
}

public static void main ( String [ ] args ) { MyScanner sc = new MyScanner ( ) ; out = new PrintWriter ( new BufferedOutputStream ( System . out ) ) ; int n = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int [ ] g = new int [ n ] ; for ( int i = 0 ; i < m ; ++ i ) { int x = sc . nextInt ( ) - 1 ; int y = sc . nextInt ( ) - 1 ; g [ x ] |= 1 << y ; } long [ ] dp = new long [ 1 << n ] ; dp [ 0 ] = 1 ; for ( int b = 1 ; b < 1 << n ; ++ b ) { for ( int i = 0 ; i < n ; ++ i ) { if ( ( b & 1 << i ) == 0 ) continue ; if ( ( ( b ^ 1 << i ) & g [ i ] ) == 0 ) dp [ b ] += dp [ b ^ 1 << i ] ; } } out . println ( dp [ ( 1 << n ) - 1 ] ) ; out . close ( ) ; }
(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)))) (expression_statement (assignment_expression left: (identifier) right: (object_creation_expression type: (type_identifier) arguments: (argument_list (object_creation_expression type: (type_identifier) arguments: (argument_list (field_access object: (identifier) field: (identifier)))))))) (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: (array_type element: (integral_type) dimensions: (dimensions)) declarator: (variable_declarator name: (identifier) value: (array_creation_expression type: (integral_type) dimensions: (dimensions_expr (identifier))))) (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 (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)) right: (decimal_integer_literal)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)) right: (decimal_integer_literal)))) (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (binary_expression left: (decimal_integer_literal) right: (identifier)))))) (local_variable_declaration type: (array_type element: (integral_type) dimensions: (dimensions)) declarator: (variable_declarator name: (identifier) value: (array_creation_expression type: (integral_type) dimensions: (dimensions_expr (binary_expression left: (decimal_integer_literal) right: (identifier)))))) (expression_statement (assignment_expression left: (array_access array: (identifier) index: (decimal_integer_literal)) right: (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: (binary_expression left: (decimal_integer_literal) right: (identifier))) update: (update_expression (identifier)) body: (block (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: (parenthesized_expression (binary_expression left: (identifier) right: (binary_expression left: (decimal_integer_literal) right: (identifier)))) right: (decimal_integer_literal))) consequence: (continue_statement)) (if_statement condition: (parenthesized_expression (binary_expression left: (parenthesized_expression (binary_expression left: (parenthesized_expression (binary_expression left: (identifier) right: (binary_expression left: (decimal_integer_literal) right: (identifier)))) right: (array_access array: (identifier) index: (identifier)))) right: (decimal_integer_literal))) consequence: (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (array_access array: (identifier) index: (binary_expression left: (identifier) right: (binary_expression left: (decimal_integer_literal) right: (identifier))))))))))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (array_access array: (identifier) index: (binary_expression left: (parenthesized_expression (binary_expression left: (decimal_integer_literal) right: (identifier))) right: (decimal_integer_literal)))))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))))