The present invention provides a compound having an inhibitory action on amyloid β production, particularly a BACE1 inhibitory action, and useful as a therapeutic or prophylactic agent for diseases induced by production, secretion or deposition of amyloid β protein. Formula (I): wherein X is -C (R3a) (R3b)-, -C (R3a) (R3b) -C (R3c) (R3d)-or -C (R3a) = C (R3c)- R1 is substituted or unsubstituted alkyl, R2a, R2b, R3a, R3b, R3c and R3d are each independently hydrogen, halogen, etc., R4 is hydrogen or halogen, and ring B is substituted Or a substituted or unsubstituted heterocyclic ring) or a pharmaceutically acceptable salt thereof.本発明は、アミロイドβ産生抑制作用、特にBACE1阻害作用を有し、アミロイドβタンパク質の産生、分泌または沈着により誘発される疾患の治療または予防剤として有用な化合物を提供する。式(I):(式中、Xは-C(R3a)(R3b)-、-C(R3a)(R3b)-C(R3c)(R3d)-または-C(R3a)=C(R3c)-であり、R1は置換若しくは非置換のアルキル等であり、R2a、R2b、R3a、R3b、R3cおよびR3dは各々独立して水素、ハロゲン等であり、R4は水素またはハロゲンであり、環Bは置換若しくは非置換の炭素環または置換若しくは非置換の複素環である)で示される化合物またはその製薬上許容される塩。