Skip to main content
Back to problems
Codeforces
Easy
Sets
Strings
Anton and Letters

Given a set-like list of lowercase letters inside braces, count how many distinct letters appear.

Acceptance 0%
Problem Statement

Problem

You are given a string that represents a collection of lowercase Latin letters inside curly braces, with commas separating the letters. Your task is to determine how many different letters appear in the collection.

The same letter may appear multiple times in the input, but it should be counted only once.

Goal

Return the number of unique lowercase letters present in the string.

Input Format

  • A single line containing a string in the form {a, b, c}.
  • The string contains lowercase English letters, commas, spaces, and curly braces.

Output Format

  • Print a single integer: the number of distinct lowercase letters in the input string.

Constraints

  • The input consists only of lowercase English letters and separators.
  • There is at least one letter in the collection.
  • The exact official limits are not required for practice; the intended solution is linear in the string length.
Examples
Sample cases returned by the problem API.

Example 1

Input

{a, b, c}

Output

3

Explanation

The distinct letters are a, b, and c.

Example 2

Input

{a, a, b, c, c}

Output

3

Explanation

Repeated letters are counted once, so the distinct letters are a, b, and c.

Premium problem context

Unlock deeper context for this problem

Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.

Guided hints
Editorial and discussion links
Concept map and variants
Sign in to unlock
Track your progress
Sign in to bookmark this problem, save notes, and manage its revision plan.