#C1631. Taco Coin Collection

    ID: 44858 Type: Default 1000ms 256MiB

Taco Coin Collection

Taco Coin Collection

Alice is on a coin collecting spree over \(N\) days. However, there's a twist: if she collects more than \(M\) coins on any day, the magic tree punishes her, and she loses all the coins for that day. Otherwise, she safely keeps the coins collected.

Your task is to help determine the maximum number of coins Alice can secure over the entire period. For each day, only coins not exceeding \(M\) are counted towards her total.

inputFormat

The input consists of two lines:

  1. The first line contains two space-separated integers, \(N\) (the number of days) and \(M\) (the maximum number of coins Alice can safely collect in a day).
  2. The second line contains \(N\) space-separated integers, where each integer represents the number of coins collected by Alice on each day.

outputFormat

Output a single integer representing the maximum number of coins Alice can retain over \(N\) days, following the rule that only days with coin counts \(\leq M\) contribute to the total.

## sample
5 10
3 15 8 20 7
18