Let's keep 26 bitsets bita,bitb,…,bitz, where corresponding bitset has ones only at positions where his letter is present. Updating these bitsets after queries of type 1 is trivial, let's see how to deal with queries of type 2.
Suppo