The present invention provides a compound which has an effect of inhibiting amyloid β production, especially an effect of inhibiting BACE1, and which is useful as a therapeutic or phylactic agent for diseases induced by production, secretion and/or deposition of amyloid β proteins. A compound of the formula (I) wherein X is -S- or -O-, R