#include <iostream>
#include <vector>
#include <string>
using namespace std;
int main() {
int N;
cin >> N;
vector<string> instructions(N);
for (int i = 0; i < N; i++) {
cin >> instructions[i];
}
int minMoves = 0;
string currentPosition = "down right"; // Initial position
for (int i = 0; i < N; i++) {
string nextPosition = instructions[i];
// Check if a move is necessary for each leg
if (currentPosition.find(nextPosition) == string::npos) {
minMoves++;
currentPosition = nextPosition + (currentPosition[1] != nextPosition[0] ? currentPosition[1] : nextPosition[0]);
}
}
cout << minMoves << endl;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8dmVjdG9yPgojaW5jbHVkZSA8c3RyaW5nPgoKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCmludCBtYWluKCkgewogICAgaW50IE47CiAgICBjaW4gPj4gTjsKCiAgICB2ZWN0b3I8c3RyaW5nPiBpbnN0cnVjdGlvbnMoTik7CiAgICBmb3IgKGludCBpID0gMDsgaSA8IE47IGkrKykgewogICAgICAgIGNpbiA+PiBpbnN0cnVjdGlvbnNbaV07CiAgICB9CgogICAgaW50IG1pbk1vdmVzID0gMDsKICAgIHN0cmluZyBjdXJyZW50UG9zaXRpb24gPSAiZG93biByaWdodCI7IC8vIEluaXRpYWwgcG9zaXRpb24KCiAgICBmb3IgKGludCBpID0gMDsgaSA8IE47IGkrKykgewogICAgICAgIHN0cmluZyBuZXh0UG9zaXRpb24gPSBpbnN0cnVjdGlvbnNbaV07CgogICAgICAgIC8vIENoZWNrIGlmIGEgbW92ZSBpcyBuZWNlc3NhcnkgZm9yIGVhY2ggbGVnCiAgICAgICAgaWYgKGN1cnJlbnRQb3NpdGlvbi5maW5kKG5leHRQb3NpdGlvbikgPT0gc3RyaW5nOjpucG9zKSB7CiAgICAgICAgICAgIG1pbk1vdmVzKys7CiAgICAgICAgICAgIGN1cnJlbnRQb3NpdGlvbiA9IG5leHRQb3NpdGlvbiArIChjdXJyZW50UG9zaXRpb25bMV0gIT0gbmV4dFBvc2l0aW9uWzBdID8gY3VycmVudFBvc2l0aW9uWzFdIDogbmV4dFBvc2l0aW9uWzBdKTsKICAgICAgICB9CiAgICB9CgogICAgY291dCA8PCBtaW5Nb3ZlcyA8PCBlbmRsOwoKICAgIHJldHVybiAwOwp9