Solve the following sql problem:
How many characters are there in Hamlet?

Schema:
SCHEMA:
- Table: chapters
  - Column: id
    - Samples: [18704, 18705, 18706, 18707, 18708]
  - Column: Act
    - Samples: [1, 1, 1, 1, 1]
  - Column: Scene
    - Samples: [1, 2, 3, 4, 5]
  - Column: Description
    - Samples: [DUKE ORSINO’s palace., The sea-coast., OLIVIA’S house., DUKE ORSINO’s palace., OLIVIA’S house.]
  - Column: work_id
    - Samples: [1, 1, 1, 1, 1]
- Table: characters
  - Column: id
    - Samples: [1, 2, 3, 4, 5]
  - Column: CharName
    - Samples: [First Apparition, First Citizen, First Conspirator, First Gentleman, First Goth]
  - Column: Abbrev
    - Samples: [First Apparition, First Citizen, First Conspirator, First Gentleman, First Goth]
  - Column: Description
    - Samples: [, , , , ]
- Table: paragraphs
  - Column: id
    - Samples: [630863, 630864, 630865, 630866, 630867]
  - Column: ParagraphNum
    - Samples: [3, 4, 19, 20, 21]
  - Column: PlainText
    - Samples: [[Enter DUKE ORSINO, CURIO, and other Lords; Musicians attending], If music be the food of love, play on;
Give me excess of it, that, sur..., Will you go hunt, my lord?, What, Curio?, The hart. (truncated)]
  - Column: character_id
    - Samples: [1261, 840, 297, 840, 297]
  - Column: chapter_id
    - Samples: [18704, 18704, 18704, 18704, 18704]
- Table: works
  - Column: id
    - Samples: [1, 2, 3, 4, 5]
  - Column: Title
    - Samples: [Twelfth Night, All's Well That Ends Well, Antony and Cleopatra, As You Like It, Comedy of Errors]
  - Column: LongTitle
    - Samples: [Twelfth Night, Or What You Will, All's Well That Ends Well, Antony and Cleopatra, As You Like It, The Comedy of Errors]
  - Column: Date
    - Samples: [1599, 1602, 1606, 1599, 1589]
  - Column: GenreType
    - Samples: [Comedy, Comedy, Tragedy, Comedy, Comedy]

SELECT COUNT(DISTINCT T3.character_id) FROM works AS T1 INNER JOIN chapters AS T2 ON T1.id = T2.work_id INNER JOIN paragraphs AS T3 ON T2.id = T3.chapter_id WHERE T1.Title = 'Hamlet'