407252: GYM102726 D Zoom Clumps

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

D. Zoom Clumpstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output

Emily is currently in a Zoom call with some friends. Currently, she is viewing the call in a way such that everyone's videos are on and everyone is in a line.

Ansh, another person in the call, is curious if people have their video flipped. He decides that on the count of three, everyone in the call will look right. However, because some people's cameras are flipped, this may result in them looking left in everyone else's perspective!

Emily however, is more curious in how many clumps would form, where a clump is a contiguous set of people who are all looking the same direction. After everyone turned their heads, she took a screenshot of everyone's faces in a line. Given the directions that everyone is facing, help Emily determine how many clumps are in the photo!

Input

The first line contains $$$N\;(1 \le N \le 10^5)$$$, the number of people in the call.

The next $$$N$$$ lines each contain a single character L or R. An L in the $$$i^{th}$$$ line represents that the $$$i^{th}$$$ person was looking left in the photo, while an R in the $$$i^{th}$$$ line represents that the $$$i^{th}$$$ person was looking right in the photo.

Output

A single integer $$$C$$$, the number of clumps that have formed.

ExampleInput
4
R
L
L
R
Output
3

加入题单

上一题 下一题 算法标签: