You are given a single line of CSV-formatted text. Fields are separated by commas, following these rules:
- A field may optionally be wrapped in double quotes (
"). - Inside a quoted field, a comma is just an ordinary character, not a field separator.
- Inside a quoted field, a literal double-quote character is written as two consecutive double quotes (
""). - A field that is NOT wrapped in double quotes never contains a double-quote character.
The line is guaranteed to be validly formatted per these rules (every quoted field's quotes are properly opened and closed). Count how many fields the line has. A line with no commas at all (quoted or not) still has exactly one field; a trailing comma implies a trailing empty field.
Input format
Line 1: the CSV line (may be empty, which counts as one field containing the empty string).
Output format
A single integer: the number of fields.
Constraints
- 0 ≤ length of the line ≤ 300
- The line is valid per the quoting rules above