public static void main ( String [ ] args ) {
  int x , y , a , b , min , max , sum = 0 , fir , lir ;
  Scanner scanner = new Scanner ( System . in ) ;
  x = scanner . nextInt ( ) ;
  y = scanner . nextInt ( ) ;
  a = scanner . nextInt ( ) ;
  b = scanner . nextInt ( ) ;
  min = Math . min ( x , y ) ;
  max = Math . max ( x , y ) ;
  int limit = b ;
  int common = max ;
  int temp = common / min ;
  while ( temp * min != common && common <= b ) {
    common += max ;
    temp = common / min ;
  }
  temp = ( ( int ) ( a / common ) * common ) ;
  fir = ( temp >= a ) ? temp : temp + common ;
  temp = ( ( int ) ( b / common ) * common ) ;
  while ( temp <= b ) {
    temp += common ;
  }
  lir = temp - common ;
  System . out . print ( ( ( lir - fir ) / common ) + 1 ) ;
}

public static void main ( String [ ] args ) { int x , y , a , b , min , max , sum = 0 , fir , lir ; Scanner scanner = new Scanner ( System . in ) ; x = scanner . nextInt ( ) ; y = scanner . nextInt ( ) ; a = scanner . nextInt ( ) ; b = scanner . nextInt ( ) ; min = Math . min ( x , y ) ; max = Math . max ( x , y ) ; int limit = b ; int common = max ; int temp = common / min ; while ( temp * min != common && common <= b ) { common += max ; temp = common / min ; } temp = ( ( int ) ( a / common ) * common ) ; fir = ( temp >= a ) ? temp : temp + common ; temp = ( ( int ) ( b / common ) * common ) ; while ( temp <= b ) { temp += common ; } lir = temp - common ; System . out . print ( ( ( lir - fir ) / common ) + 1 ) ; }
(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: (integral_type) declarator: (variable_declarator name: (identifier)) declarator: (variable_declarator name: (identifier)) declarator: (variable_declarator name: (identifier)) declarator: (variable_declarator name: (identifier)) declarator: (variable_declarator name: (identifier)) declarator: (variable_declarator name: (identifier)) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal)) declarator: (variable_declarator name: (identifier)) declarator: (variable_declarator name: (identifier))) (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: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (identifier))))) (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (identifier))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (identifier))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (identifier))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (identifier) right: (identifier)))) (while_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (binary_expression left: (identifier) right: (identifier)) right: (identifier)) right: (binary_expression left: (identifier) right: (identifier)))) body: (block (expression_statement (assignment_expression left: (identifier) right: (identifier))) (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (identifier) right: (identifier)))))) (expression_statement (assignment_expression left: (identifier) right: (parenthesized_expression (binary_expression left: (cast_expression type: (integral_type) value: (parenthesized_expression (binary_expression left: (identifier) right: (identifier)))) right: (identifier))))) (expression_statement (assignment_expression left: (identifier) right: (ternary_expression condition: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) consequence: (identifier) alternative: (binary_expression left: (identifier) right: (identifier))))) (expression_statement (assignment_expression left: (identifier) right: (parenthesized_expression (binary_expression left: (cast_expression type: (integral_type) value: (parenthesized_expression (binary_expression left: (identifier) right: (identifier)))) right: (identifier))))) (while_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) body: (block (expression_statement (assignment_expression left: (identifier) right: (identifier))))) (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (identifier) right: (identifier)))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (binary_expression left: (parenthesized_expression (binary_expression left: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) right: (identifier))) right: (decimal_integer_literal)))))))