The present invention provides a compound of formula (I): wherein ring B is substituted or unsubstituted carbocycle or heterocycle, R 1 is substituted or unsubstituted alkyl or the like, R 2a and R 2b are each independently hydrogen, substituted or unsubstituted alkyl or the like, R 3 , R 4a and R 4b are each independently hydrogen, halogen, substituted or unsubstituted alkyl or the like, a dashed line represents a presence or absence of a bond, R 5 is hydrogen, substituted or unsubstituted alkyl or the like, R 6 is halogen, hydroxy, substituted or unsubstituted alkyl or the like, p is an integer of 0 to 3, or a pharmaceutically acceptable salt thereof which has an effect of inhibiting amyloid ² production, especially an effect of inhibiting BACE1, and which is useful as a therapeutic or prophylactic agent for diseases induced by production, secretion and/or deposition of amyloid ² proteins.