A. Generous Kefa time limit per test:2 seconds memory limit per test:256 megabytes input:standard input output:standard output One day Kefa found n baloons. For convenience, we denote color of i-th baloon as si — lowercase letter of the Latin alphabe…