All problems

Problem 895

Crawler Log Folder

Easy · 10 pts · String, Stack

Problem

A file system log records folder changes, starting in the main folder. '../' moves to the parent folder (and stays put if already in the main folder), './' stays in the same folder, and 'x/' moves into the child folder named x. After all the operations, print the minimum number of operations needed to go back to the main folder, which is simply the current depth. Track the depth with a counter.

Input

The first line contains N. The second line contains the N log entries.

Output

Print the minimum number of operations to return to the main folder.

Constraints

1 <= N <= 1000; folder names are lowercase letters and digits

Example input

5
d1/ d2/ ../ d21/ ./

Example output

2

Explanation

For d1/ d2/ ../ d21/ ./, the depth goes 1, 2, 1, 2 and stays 2, so two '../' operations are needed to get back.

Every problem here can be used in a RelayTrixCode team match. Create a room.

Previous: Make The String Great Next: Build an Array With Stack Operations