public static void main ( String [ ] args ) {
  Scanner sc = new Scanner ( System . in ) ;
  s = sc . next ( ) ;
  t = sc . next ( ) ;
  N = s . length ( ) ;
  M = t . length ( ) ;
  next = new int [ M ] ;
  for ( int i = 1 , j = 0 ;
  i < M ;
  i ++ ) {
    while ( j > 0 && t . charAt ( i ) != t . charAt ( j ) ) j = next [ j - 1 ] ;
    if ( t . charAt ( i ) == t . charAt ( j ) ) j ++ ;
    next [ i ] = j ;
  }
  boolean [ ] flag = new boolean [ N + 1 ] ;
  for ( int i = 0 , j = 0 ;
  i < N ;
  i ++ ) {
    while ( j > 0 && ( j == M || s . charAt ( i ) != t . charAt ( j ) ) ) j = next [ j - 1 ] ;
    if ( s . charAt ( i ) == t . charAt ( j ) ) j ++ ;
    if ( j == M ) {
      flag [ i + 1 ] = true ;
    }
  }
  dp = new long [ N + 1 ] ;
  s1 = new long [ N + 1 ] ;
  s2 = new long [ N + 1 ] ;
  for ( int i = 1 ;
  i <= N ;
  i ++ ) {
    if ( ! flag [ i ] ) {
      dp [ i ] = dp [ i - 1 ] ;
    }
    else {
      dp [ i ] = ( ( i - M + 1 ) + s2 [ i - M ] ) % MOD ;
    }
    s1 [ i ] = ( s1 [ i - 1 ] + dp [ i ] ) % MOD ;
    s2 [ i ] = ( s2 [ i - 1 ] + s1 [ i ] ) % MOD ;
  }
  System . out . println ( s1 [ N ] ) ;
}

public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; s = sc . next ( ) ; t = sc . next ( ) ; N = s . length ( ) ; M = t . length ( ) ; next = new int [ M ] ; for ( int i = 1 , j = 0 ; i < M ; i ++ ) { while ( j > 0 && t . charAt ( i ) != t . charAt ( j ) ) j = next [ j - 1 ] ; if ( t . charAt ( i ) == t . charAt ( j ) ) j ++ ; next [ i ] = j ; } boolean [ ] flag = new boolean [ N + 1 ] ; for ( int i = 0 , j = 0 ; i < N ; i ++ ) { while ( j > 0 && ( j == M || s . charAt ( i ) != t . charAt ( j ) ) ) j = next [ j - 1 ] ; if ( s . charAt ( i ) == t . charAt ( j ) ) j ++ ; if ( j == M ) { flag [ i + 1 ] = true ; } } dp = new long [ N + 1 ] ; s1 = new long [ N + 1 ] ; s2 = new long [ N + 1 ] ; for ( int i = 1 ; i <= N ; i ++ ) { if ( ! flag [ i ] ) { dp [ i ] = dp [ i - 1 ] ; } else { dp [ i ] = ( ( i - M + 1 ) + s2 [ i - M ] ) % MOD ; } s1 [ i ] = ( s1 [ i - 1 ] + dp [ i ] ) % MOD ; s2 [ i ] = ( s2 [ i - 1 ] + s1 [ i ] ) % MOD ; } System . out . println ( s1 [ N ] ) ; }
(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)))))) (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (expression_statement (assignment_expression left: (identifier) right: (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)) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (block (while_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (identifier) right: (decimal_integer_literal)) right: (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier)))))) body: (expression_statement (assignment_expression left: (identifier) right: (array_access array: (identifier) index: (binary_expression left: (identifier) right: (decimal_integer_literal)))))) (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: (expression_statement (update_expression (identifier)))) (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (identifier))))) (local_variable_declaration type: (array_type element: (boolean_type) dimensions: (dimensions)) declarator: (variable_declarator name: (identifier) value: (array_creation_expression type: (boolean_type) dimensions: (dimensions_expr (binary_expression left: (identifier) right: (decimal_integer_literal)))))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal)) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (block (while_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (identifier) right: (decimal_integer_literal)) right: (parenthesized_expression (binary_expression left: (binary_expression left: (identifier) right: (identifier)) right: (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier)))))))) body: (expression_statement (assignment_expression left: (identifier) right: (array_access array: (identifier) index: (binary_expression left: (identifier) right: (decimal_integer_literal)))))) (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: (expression_statement (update_expression (identifier)))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) consequence: (block (expression_statement (assignment_expression left: (array_access array: (identifier) index: (binary_expression left: (identifier) right: (decimal_integer_literal))) right: (true))))))) (expression_statement (assignment_expression left: (identifier) right: (array_creation_expression type: (integral_type) dimensions: (dimensions_expr (binary_expression left: (identifier) right: (decimal_integer_literal)))))) (expression_statement (assignment_expression left: (identifier) right: (array_creation_expression type: (integral_type) dimensions: (dimensions_expr (binary_expression left: (identifier) right: (decimal_integer_literal)))))) (expression_statement (assignment_expression left: (identifier) right: (array_creation_expression type: (integral_type) dimensions: (dimensions_expr (binary_expression left: (identifier) 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: (identifier)) update: (update_expression (identifier)) body: (block (if_statement condition: (parenthesized_expression (unary_expression operand: (array_access array: (identifier) index: (identifier)))) consequence: (block (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (array_access array: (identifier) index: (binary_expression left: (identifier) right: (decimal_integer_literal)))))) alternative: (block (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (binary_expression left: (parenthesized_expression (binary_expression left: (parenthesized_expression (binary_expression left: (binary_expression left: (identifier) right: (identifier)) right: (decimal_integer_literal))) right: (array_access array: (identifier) index: (binary_expression left: (identifier) right: (identifier))))) right: (identifier)))))) (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (binary_expression left: (parenthesized_expression (binary_expression left: (array_access array: (identifier) index: (binary_expression left: (identifier) right: (decimal_integer_literal))) right: (array_access array: (identifier) index: (identifier)))) right: (identifier)))) (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (binary_expression left: (parenthesized_expression (binary_expression left: (array_access array: (identifier) index: (binary_expression left: (identifier) right: (decimal_integer_literal))) right: (array_access array: (identifier) index: (identifier)))) right: (identifier)))))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (array_access array: (identifier) index: (identifier)))))))