Cheek kissing departing. It is uncommon between strangers of any sex, and it may be considered offensive otherwise. It is standard for children and parents, children and grandparents etc., and in its "formal" form it will be two kisses, one on each cheek. It may be a standard formal form of greeting in special events such as weddings. However, in Portugal and Spain, usually, women kiss both men and women, and men only kiss women (so, 2 men rarely kiss). In Portuguese families men rarely kiss men (except between brothers or father and son) , the handshake is the most common salutation
Cheek kissing by leaning to the left side and joining the right cheeks and if there's a second kiss, changing to the left cheeks. In some cases (e.g. some parts of Italy) the process is the opposite, you first lean to the right, join the left cheeks and then switch to the right cheeks. In the former Yugoslavia, cheek kissing is also very commonplace, with your nationality being ascertainable by the number of kisses on each cheek. Typically, Croats and Bosniaks will kiss once on each cheek, for two total kisses, whereas Serbs (be they from Bosnia, Croatia, Serbia or Montenegro) will