I hope that you have noticed the challenge of maintaining the indentations in a program like this (my version) which contains nested if-else structures.
If the nesting gets too tough, it might be time to consider "re-factoring" your program:
void loop() {
input = keypad.getKey(); //L0:
if(input) { //L1:
if(flag2==0x00) {
process_flag200();
} else {
if(input == '*') {
process_asterix();
} else if(flag3 == 0x00 && input == 'b') {
process_b();
}
}
}
}