#K6961. Account Balance Transactions

    ID: 33125 Type: Default 1000ms 256MiB

Account Balance Transactions

Account Balance Transactions

You are given a list of financial transactions, each representing either a deposit or a withdrawal. Initially, the account balance is \(0\). Each transaction is provided in the format:

  • D <amount> for a deposit, where \(\text{amount}\) is a positive integer.
  • W <amount> for a withdrawal, where \(\text{amount}\) is a positive integer.

When processing a withdrawal, if subtracting the \(\text{amount}\) would result in a negative balance, the transaction is ignored. Your task is to compute the final account balance after processing all transactions.

Input Format: The first line contains an integer \(N\), the number of transactions. Each of the next \(N\) lines contains a transaction in the format described above.

Output Format: Output a single integer representing the final account balance.

inputFormat

The input is given via stdin as follows:

  1. The first line contains an integer \(N\) — the number of transactions.
  2. The following \(N\) lines each contain a transaction in one of the formats: "D <amount>" for deposits or "W <amount>" for withdrawals.

outputFormat

The output should be written to stdout and consist of a single integer — the final balance after processing all transactions.

## sample
4
D 300
W 200
D 100
W 500
200