This invention relates to compounds of the formula wherein A, B and R1 to R7 are as described below, or to pharmaceutically acceptable salts thereof. These compounds are BACE1 and/or BACE2 inhibitors and can be used as medicaments for the therapeutic and/or prophylactic treatment of diseases such as Alzheimer's disease, diabetes, particularly type 2 diabetes, and other metabolic disorders.