package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"math/rand"
	"time"
)

var reader *bufio.Reader = bufio.NewReader(os.Stdin)
var writer *bufio.Writer = bufio.NewWriter(os.Stdout)
func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }
func scanf(f string, a ...interface{}) { fmt.Fscanf(reader, f, a...) }

func max(a,b int) int {
	if a>b {
		return a
	} else {
		return b
	}
}
func min(a,b int) int {
	if a>b {
		return b
	} else {
		return a
	}
}

type vector_i []int
func (v *vector_i) pb(x int) {
	*v=append(*v,x)
}
func (v *vector_i) size() int {
	return len(*v)
}
func (v *vector_i) pop() {
	if !(*v).empty() {
		*v=(*v)[:len(*v)-1]
	}
}
func (v *vector_i) reverse() {
	n:=(*v).size()
	for i:=0;i*2<n;i++ {
		(*v)[i],(*v)[n-i-1]=(*v)[n-i-1],(*v)[i]
	}
}
func (v *vector_i) clear() {
	*v=(*v)[:0]
}
func (v *vector_i) empty() bool {
	return (*v).size()==0
}
func (v *vector_i) sort() {
	sort.Slice(*v, func (i, j int) bool {
		return (*v)[i]<(*v)[j]
	})
}
type fun_ii_b func (i, j int) bool
func (v *vector_i) sort_fun(f fun_ii_b) {
	sort.Slice(*v,f)
}
func (v *vector_i) lb(x int) int {
	var l,r int = 0,(*v).size()
	for l<r {
		mid:=(l+r)/2
		if (*v)[mid]<x {
			l=mid+1
		} else {
			r=mid
		}
	}
	return l
}
func (v *vector_i) ub(x int) int {
	var l,r int = 0,(*v).size()
	for l<r {
		mid:=(l+r)/2
		if (*v)[mid]<=x {
			l=mid+1
		} else {
			r=mid
		}
	}
	return l
}
func (v *vector_i) del(pos int) {
	if pos>=0 && pos<len(*v) {
		for i:=pos;i<len(*v)-1;i++ {
			(*v)[i]=(*v)[i+1]
		}
		(*v).pop()
	}
}
func (v *vector_i) ins(pos, val int) {
	(*v).pb(0)
	for i:=len(*v)-1;i>pos;i-- {
		(*v)[i]=(*v)[i-1]
	}
	(*v)[pos]=val
}
func (v *vector_i) substr(l, r int) vector_i {
	var ans vector_i=make(vector_i,r-l+1)
	for i:=l;i<=r;i++ {
		ans.pb((*v)[i])
	}
	return ans
}
func (v *vector_i) resize(n int) {
	for len(*v)>n {
		(*v).pop()
	}
	for len(*v)<n {
		(*v).pb(0)
	}
}

type Treap struct {
	ls,rs,sz,x,y vector_i
	root int
	multi bool
}
func (t *Treap) init(multi bool) {
	t.ls.resize(1)
	t.rs.resize(1)
	t.sz.resize(1)
	t.x.resize(1)
	t.y.resize(1)
	t.root=0
	t.multi=multi
	rand.Seed(time.Now().UnixNano())
}
const lim_rand int=2000000000
func (t *Treap) MakeNode(x int) int {
	t.ls.pb(0)
	t.rs.pb(0)
	t.sz.pb(1)
	t.x.pb(x)
	t.y.pb(rand.Intn(lim_rand))
	return t.x.size()-1;
}
func (t *Treap) val(c int) int {
	return t.x[c]
}
func (t *Treap) pull(c int) {
	t.sz[c]=t.sz[t.ls[c]]+1+t.sz[t.rs[c]]
}
func (t *Treap) upd(c int) {

}
func (t *Treap) push(c int) {

}
func (t *Treap) Split_val(c int, l,r *int, x int) {
	if c==0 {
		*l=0
		*r=0
	} else {
		(*t).push(c)
		if t.x[c]<=x {
			*l=c
			(*t).Split_val(t.rs[c],&t.rs[*l],r,x)
		} else {
			*r=c
			(*t).Split_val(t.ls[c],l,&t.ls[*r],x)
		}
		(*t).pull(c)
	}
}
func (t *Treap) Split_sz(c int, l,r *int, k int) {
	if c==0 {
		*l=0
		*r=0
	} else {
		(*t).push(c)
		if t.sz[t.ls[c]]+1<=k {
			*l=c
			(*t).Split_sz(t.rs[c],&t.rs[*l],r,k-t.sz[t.ls[c]]-1)
		} else {
			*r=c
			(*t).Split_sz(t.ls[c],l,&t.ls[*r],k)
		}
		(*t).pull(c)
	}
}
func (t *Treap) Merge(c *int, l,r int) {
	if l==0 || r==0 {
		*c=l^r;
	} else {
		if t.y[l]>t.y[r] {
			(*t).push(l)
			*c=l
			(*t).Merge(&t.rs[*c],t.rs[l],r)
		} else {
			(*t).push(r)
			*c=r
			(*t).Merge(&t.ls[*c],l,t.ls[r])
		}
		(*t).pull(*c)
	}
}
func (t *Treap) Search_pos(c,k int) int {
	if c==0 {
		return 0
	} else {
		(*t).push(c)
		if t.sz[t.ls[c]]+1==k {
			return c
		} else if t.sz[t.ls[c]]+1<k {
			return (*t).Search_pos(t.rs[c],k-t.sz[t.ls[c]]-1)
		} else {
			return (*t).Search_pos(t.ls[c],k)
		}
	}
}
func (t *Treap) has(c,x int) bool {
	if c==0 {
		return false
	} else {
		(*t).push(c)
		if t.x[c]==x {
			return true
		} else if t.x[c]<x {
			return (*t).has(t.rs[c],x)
		} else {
			return (*t).has(t.ls[c],x)
		}
	}
}
func (t *Treap) ins(x int) {
	if t.multi || !(*t).has(t.root,x) {
		tmp:=(*t).MakeNode(x)
		var a,b int=0,0
		(*t).Split_val(t.root,&a,&b,x)
		(*t).Merge(&t.root,a,tmp)
		(*t).Merge(&t.root,t.root,b)
	}
}
func (t *Treap) del_val(x int) {
	var a,b,c int=0,0,0
	(*t).Split_val(t.root,&a,&b,x-1)
	(*t).Split_val(b,&b,&c,x)
	(*t).Merge(&t.root,a,c)
}
func (t *Treap) del_pos(k int) {
	var a,b,c int=0,0,0
	(*t).Split_sz(t.root,&a,&b,k-1)
	(*t).Split_sz(b,&b,&c,1)
	(*t).Merge(&t.root,a,c)
}
func (t *Treap) at(k int) int {
	return (*t).Search_pos(t.root,k)
}
func (t *Treap) val_at(k int) int {
	return t.x[(*t).at(k)]
}
func (t *Treap) Search_lb(c,x int) int {
	if c==0 {
		return 0
	} else {
		(*t).push(c)
		if t.x[c]==x {
			return c
		} else if t.x[c]<x {
			return (*t).Search_lb(t.rs[c],x)
		} else {
			ans:=(*t).Search_lb(t.ls[c],x)
			if ans==0 {
				ans=c
			}
			return ans
		}
	}
}
func (t *Treap) lb(x int) int {
	return (*t).Search_lb(t.root,x)
}
func (t *Treap) ub(x int) int {
	return (*t).Search_lb(t.root,x+1)
}
func (t *Treap) size() int {
	return t.sz[t.root]
}
func (t *Treap) print(c int) {
	if c!=0 {
		(*t).print(t.ls[c])
		printf("(%d %d) ",t.x[c],t.sz[c])
		(*t).print(t.rs[c])
	}
}

func main() {

	defer writer.Flush()

	var st [26]Treap
	for i:=0;i<26;i++ {
		st[i].init(false)
	}
	var str string
	var byt []byte
	byt=append(byt,0)
	scanf("%s\n",&str)
	for i:=1;i<=len(str);i++ {
		x:=int(str[i-1])-int('a')
		byt=append(byt,str[i-1])
		st[x].ins(i)
	}
	var q int
	scanf("%d\n",&q)
	for ;q>0;q-- {
		var t int
		scanf("%d ",&t)
		if t==1 {
			var p int
			var c byte
			scanf("%d %c\n",&p,&c)
			x:=int(byt[p])-int('a')
			y:=int(c)-int('a')
			byt[p]=c
			st[x].del_val(p)
			st[y].ins(p)
		} else {
			var l,r int
			scanf("%d %d\n",&l,&r)
			ans:=0
			for i:=0;i<26;i++ {
				lb:=st[i].lb(l)
				if lb!=0 && st[i].val(lb)<=r {
					ans++
				}
			}
			printf("%d\n",ans)
		}
	}
}

package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
	"strings"
)

var pc [256]byte

func init() {
	for i := range pc {
		pc[i] = pc[i/2] + byte(i&1)
	}
}

func PopCount(x uint32) int {
	return int(pc[byte(x)] +
		pc[byte(x>>8)] +
		pc[byte(x>>16)] +
		pc[byte(x>>24)])
}

func main() {
	f(os.Stdin, os.Stdout)
}

type Block struct {
	Mask  uint32
	Items []uint32
}

func (b *Block) SetItem(pos int, item uint32) {
	b.Items[pos] = item
	b.Mask = 0
	for _, item := range b.Items {
		b.Mask |= item
	}
}

func (b *Block) GetMask(pos1, pos2 int) uint32 {
	mask := uint32(0)
	for i := pos1; i < pos2; i += 1 {
		mask |= b.Items[i]
	}

	return mask
}

func f(in io.Reader, out io.Writer) {
	s := bufio.NewScanner(in)
	s.Buffer(make([]byte, 0, 100002), 100002)

	blockSize := 100
	blocks := make([]Block, 0)

	data := []byte(read(s))

	// Дополняем строку до длины блока
	sLen := len(data)
	z := 0
	if sLen < 8 {
		z = blockSize - sLen
	} else {
		z = blockSize - sLen%blockSize
	}
	data = append(data, make([]byte, z)...)

	// Разбиваем эл-ты на блоки
	for i := 0; i < len(data); i += blockSize {
		block := Block{
			Items: make([]uint32, blockSize),
		}
		for j := 0; j < blockSize; j += 1 {
			block.SetItem(j, 1<<(data[i+j]-'a'))
		}
		blocks = append(blocks, block)
	}

	q, _ := strconv.ParseUint(read(s), 10, 32)
	for i := 0; uint64(i) < q; i += 1 {
		req := strings.Split(read(s), " ")
		switch req[0][0] {
		case '1':
			pos, _ := strconv.ParseUint(req[1], 10, 64)
			n1 := (pos - 1) / uint64(blockSize)
			n2 := int(pos-1) % blockSize
			blocks[n1].SetItem(n2, 1<<(req[2][0]-'a'))
		case '2':
			pos1, _ := strconv.ParseUint(req[1], 10, 64)
			pos2, _ := strconv.ParseUint(req[2], 10, 64)

			n11 := (pos1 - 1) / uint64(blockSize)
			n12 := int(pos1-1) % blockSize
			n21 := (pos2) / uint64(blockSize)
			n22 := int(pos2) % blockSize

			counters := uint32(0)

			// Считаем биты крайних блоков
			if n11 == n21 {
				counters |= blocks[n11].GetMask(n12, n22)
			} else {
				counters |= blocks[n11].GetMask(n12, blockSize)
				counters |= blocks[n21].GetMask(0, n22)
				// считаем биты полных блоков
				for j := n11 + 1; j < n21; j++ {
					counters |= blocks[j].Mask
				}
			}

			_, _ = fmt.Fprintln(out, PopCount(counters))
		}
	}
}

func read(s *bufio.Scanner) string {
	s.Scan()
	return s.Text()
}

// Author: sighduck
// URL: https://codeforces.com/problemset/problem/1234/D

package main

import (
	"bufio"
	"fmt"
	"os"
)

type ReplaceQuery struct {
	queryType int
	index     int
	char      string
}

type CalculateQuery struct {
	queryType int
	left      int
	right     int
}

func update(tree []int, index int, value int) {
	for index <= len(tree)-1 {
		tree[index] += value
		index += index & ^(index - 1)
	}
}

func sum(tree []int, index int) int {
	total := 0
	for index > 0 {
		total += tree[index]
		index -= index & ^(index - 1)
	}
	return total
}

func Solve(s string, n int, queries []interface{}) []int {
	trees := make([][]int, 26)
	for i := 0; i < 26; i++ {
		trees[i] = make([]int, len(s)+1)
	}
	for i := 1; i <= len(s); i++ {
		update(trees[s[i-1]-'a'], i, 1)
	}
	answers := []int{}
	b := []byte(s)
	for _, query := range queries {
		switch query.(type) {
		case ReplaceQuery:
			r := query.(ReplaceQuery)
			update(trees[b[r.index-1]-'a'], r.index, -1)
			b[r.index-1] = r.char[0]
			update(trees[b[r.index-1]-'a'], r.index, 1)
		case CalculateQuery:
			c := query.(CalculateQuery)
			distinct := 0
			for _, tree := range trees {
				if sum(tree, c.right)-sum(tree, c.left-1) > 0 {
					distinct += 1
				}
			}
			answers = append(answers, distinct)
		}
	}
	return answers
}

func main() {
	reader := bufio.NewReader(os.Stdin)
	writer := bufio.NewWriter(os.Stdout)
	defer writer.Flush()

	var s string
	var n int
	fmt.Fscanf(reader, "%s\n%d\n", &s, &n)
	queries := make([]interface{}, n)
	for i := 0; i < n; i++ {
		var queryType int
		fmt.Fscanf(reader, "%d", &queryType)
		if queryType == 1 {
			r := ReplaceQuery{queryType, 0, ""}
			fmt.Fscanf(reader, "%d %s\n", &r.index, &r.char)
			queries[i] = r
		} else if queryType == 2 {
			c := CalculateQuery{queryType, 0, 0}
			fmt.Fscanf(reader, "%d %d\n", &c.left, &c.right)
			queries[i] = c
		}
	}

	answers := Solve(s, n, queries)
	for _, elem := range answers {
		fmt.Fprintf(writer, "%d\n", elem)
	}
}

package main

import (
	"bufio"
	. "fmt"
	"io"
	"os"
)

// github.com/EndlessCheng/codeforces-go
func Sol1234D(reader io.Reader, writer io.Writer) {
	in := bufio.NewReader(reader)
	out := bufio.NewWriter(writer)
	defer out.Flush()

	var s []byte
	Fscan(in, &s)
	for i := range s {
		s[i] -= 'a'
	}

	n := len(s)
	trees := make([][]int, 26)
	for i := range trees {
		trees[i] = make([]int, n+1)
	}
	add := func(tree []int, idx int, val int) {
		for ; idx <= n; idx += idx & -idx {
			tree[idx] += val
		}
	}
	sum := func(tree []int, idx int) (res int) {
		for ; idx > 0; idx &= idx - 1 {
			res += tree[idx]
		}
		return
	}
	query := func(tree []int, l, r int) int {
		return sum(tree, r) - sum(tree, l-1)
	}

	for i, c := range s {
		add(trees[c], i+1, 1)
	}
	var q, op int
	for Fscan(in, &q); q > 0; q-- {
		if Fscan(in, &op); op == 1 {
			var idx int
			var raw string
			Fscan(in, &idx, &raw)
			ch := raw[0] - 'a'
			add(trees[s[idx-1]], idx, -1)
			add(trees[ch], idx, 1)
			s[idx-1] = ch
		} else {
			var l, r int
			Fscan(in, &l, &r)
			res := 0
			for _, tree := range trees {
				if query(tree, l, r) > 0 {
					res++
				}
			}
			Fprintln(out, res)
		}
	}
}

func main() {
	Sol1234D(os.Stdin, os.Stdout)
}

package main

import (
	"bufio"
	. "fmt"
	"io"
	"os"
)

// github.com/EndlessCheng/codeforces-go
func Sol1234D(reader io.Reader, writer io.Writer) {
	in := bufio.NewReader(reader)
	out := bufio.NewWriter(writer)
	defer out.Flush()

	var s []byte
	Fscan(in, &s)
	for i := range s {
		s[i] -= 'a'
	}

	n := len(s)
	trees := make([][]int, 26)
	for i := range trees {
		trees[i] = make([]int, n+1)
	}
	add := func(tree []int, idx int, val int) {
		for ; idx <= n; idx += idx & -idx {
			tree[idx] += val
		}
	}
	sum := func(tree []int, idx int) (res int) {
		for ; idx > 0; idx &= idx - 1 {
			res += tree[idx]
		}
		return
	}
	query := func(tree []int, l, r int) int {
		return sum(tree, r) - sum(tree, l-1)
	}

	for i, c := range s {
		add(trees[c], i+1, 1)
	}
	var q, op int
	for Fscan(in, &q); q > 0; q-- {
		Fscan(in, &op)
		if op == 1 {
			var idx int
			var raw string
			Fscan(in, &idx, &raw)
			ch := raw[0] - 'a'
			add(trees[s[idx-1]], idx, -1)
			add(trees[ch], idx, 1)
			s[idx-1] = ch
		} else {
			var l, r int
			Fscan(in, &l, &r)
			res := 0
			for i := range trees {
				if query(trees[i], l, r) > 0 {
					res++
				}
			}
			Fprintln(out, res)
		}
	}
}

func main() {
	Sol1234D(os.Stdin, os.Stdout)
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	reader := bufio.NewReader(os.Stdin)

	var ss string
	fmt.Fscanf(reader, "%s\n", &ss)

	s := []byte(ss)
	ll := len(ss)

	var data [101][26]int

	for i := 0; i*1000 < ll; i++ {

		for j := i * 1000; j < ll && j < (i+1)*1000; j++ {
			data[i][s[j]-'a']++
		}
	}

	var q int
	fmt.Fscanf(reader, "%d\n", &q)

	var t int
	var l, r int
	var c byte
	for i := 0; i < q; i++ {
		fmt.Fscanf(reader, "%d", &t)
		if t == 1 {
			fmt.Fscanf(reader, "%d %c\n", &l, &c)
			data[(l-1)/1000][s[l-1]-'a']--

			s[l-1] = c
			data[(l-1)/1000][s[l-1]-'a']++
		} else {
			fmt.Fscanf(reader, "%d %d\n", &l, &r)

			var ans [26]bool

			//[l-1, 1000x)
			for l = l - 1; l < r; l++ {
				if (l+1)%1000 == 0 {
					break
				}

				if !ans[s[l]-'a'] {
					ans[s[l]-'a'] = true
				}
			}

			//[1000x, 1000y)
			for ; (l+1)/1000 < r/1000; l += 1000 {
				k := (l + 1) / 1000
				for j := 0; j < 26; j++ {
					if !ans[j] && data[k][j] > 0 {
						ans[j] = true
					}
				}
			}

			//[1000y, r)
			for ; l < r; l++ {
				if !ans[s[l]-'a'] {
					ans[s[l]-'a'] = true
				}
			}

			//ans
			sum := 0
			for j := 0; j < 26; j++ {
				if ans[j] {
					sum++
				}
			}
			fmt.Printf("%d\n", sum)
		}
	}
}

package main

import (
	"bufio"
	"errors"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
)

/*********** I/O ***********/

var (
	// ReadString returns a WORD string.
	ReadString func() string
	stdout     *bufio.Writer
)

func init() {
	ReadString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	// r.Buffer(make([]byte, 1024), int(1e+11)) // for AtCoder
	r.Buffer(make([]byte, 1024), int(1e+9)) // for Codeforces
	// Split sets the split function for the Scanner. The default split function is ScanLines.
	// Split panics if it is called after scanning has started.
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

// ReadInt returns an integer.
func ReadInt() int {
	return int(readInt64())
}
func ReadInt2() (int, int) {
	return int(readInt64()), int(readInt64())
}
func ReadInt3() (int, int, int) {
	return int(readInt64()), int(readInt64()), int(readInt64())
}
func ReadInt4() (int, int, int, int) {
	return int(readInt64()), int(readInt64()), int(readInt64()), int(readInt64())
}

// ReadInt64 returns as integer as int64.
func ReadInt64() int64 {
	return readInt64()
}
func ReadInt64_2() (int64, int64) {
	return readInt64(), readInt64()
}
func ReadInt64_3() (int64, int64, int64) {
	return readInt64(), readInt64(), readInt64()
}
func ReadInt64_4() (int64, int64, int64, int64) {
	return readInt64(), readInt64(), readInt64(), readInt64()
}

func readInt64() int64 {
	i, err := strconv.ParseInt(ReadString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

// ReadIntSlice returns an integer slice that has n integers.
func ReadIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = ReadInt()
	}
	return b
}

// ReadInt64Slice returns as int64 slice that has n integers.
func ReadInt64Slice(n int) []int64 {
	b := make([]int64, n)
	for i := 0; i < n; i++ {
		b[i] = ReadInt64()
	}
	return b
}

// ReadFloat64 returns an float64.
func ReadFloat64() float64 {
	return float64(readFloat64())
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(ReadString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

// ReadFloatSlice returns an float64 slice that has n float64.
func ReadFloat64Slice(n int) []float64 {
	b := make([]float64, n)
	for i := 0; i < n; i++ {
		b[i] = ReadFloat64()
	}
	return b
}

// ReadRuneSlice returns a rune slice.
func ReadRuneSlice() []rune {
	return []rune(ReadString())
}

/*********** Debugging ***********/

// ZeroPaddingRuneSlice returns binary expressions of integer n with zero padding.
// For debugging use.
func ZeroPaddingRuneSlice(n, digitsNum int) []rune {
	sn := fmt.Sprintf("%b", n)

	residualLength := digitsNum - len(sn)
	if residualLength <= 0 {
		return []rune(sn)
	}

	zeros := make([]rune, residualLength)
	for i := 0; i < len(zeros); i++ {
		zeros[i] = '0'
	}

	res := []rune{}
	res = append(res, zeros...)
	res = append(res, []rune(sn)...)

	return res
}

/*********** DP sub-functions ***********/

// ChMin accepts a pointer of integer and a target value.
// If target value is SMALLER than the first argument,
//	then the first argument will be updated by the second argument.
func ChMin(updatedValue *int, target int) bool {
	if *updatedValue > target {
		*updatedValue = target
		return true
	}
	return false
}

// ChMax accepts a pointer of integer and a target value.
// If target value is LARGER than the first argument,
//	then the first argument will be updated by the second argument.
func ChMax(updatedValue *int, target int) bool {
	if *updatedValue < target {
		*updatedValue = target
		return true
	}
	return false
}

// NthBit returns nth bit value of an argument.
// n starts from 0.
func NthBit(num, nth int) int {
	return num >> uint(nth) & 1
}

// OnBit returns the integer that has nth ON bit.
// If an argument has nth ON bit, OnBit returns the argument.
func OnBit(num, nth int) int {
	return num | (1 << uint(nth))
}

// OffBit returns the integer that has nth OFF bit.
// If an argument has nth OFF bit, OffBit returns the argument.
func OffBit(num, nth int) int {
	return num & ^(1 << uint(nth))
}

// PopCount returns the number of ON bit of an argument.
func PopCount(num int) int {
	res := 0

	for i := 0; i < 70; i++ {
		if ((num >> uint(i)) & 1) == 1 {
			res++
		}
	}

	return res
}

/*********** Arithmetic ***********/

// Max returns the max integer among input set.
// This function needs at least 1 argument (no argument causes panic).
func Max(integers ...int) int {
	m := integers[0]
	for i, integer := range integers {
		if i == 0 {
			continue
		}
		if m < integer {
			m = integer
		}
	}
	return m
}

// Min returns the min integer among input set.
// This function needs at least 1 argument (no argument causes panic).
func Min(integers ...int) int {
	m := integers[0]
	for i, integer := range integers {
		if i == 0 {
			continue
		}
		if m > integer {
			m = integer
		}
	}
	return m
}

// DigitSum returns digit sum of a decimal number.
// DigitSum only accept a positive integer.
func DigitSum(n int) int {
	if n < 0 {
		return -1
	}

	res := 0

	for n > 0 {
		res += n % 10
		n /= 10
	}

	return res
}

// DigitNumOfDecimal returns digits number of n.
// n is non negative number.
func DigitNumOfDecimal(n int) int {
	res := 0

	for n > 0 {
		n /= 10
		res++
	}

	return res
}

// Sum returns multiple integers sum.
func Sum(integers ...int) int {
	s := 0

	for _, i := range integers {
		s += i
	}

	return s
}

// Kiriage returns Ceil(a/b)
// a >= 0, b > 0
func Kiriage(a, b int) int {
	return (a + (b - 1)) / b
}

// PowInt is integer version of math.Pow
// PowInt calculate a power by Binary Power (二分累乗法(O(log e))).
func PowInt(a, e int) int {
	if a < 0 || e < 0 {
		panic(errors.New("[argument error]: PowInt does not accept negative integers"))
	}

	if e == 0 {
		return 1
	}

	if e%2 == 0 {
		halfE := e / 2
		half := PowInt(a, halfE)
		return half * half
	}

	return a * PowInt(a, e-1)
}

// AbsInt is integer version of math.Abs
func AbsInt(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

// Gcd returns the Greatest Common Divisor of two natural numbers.
// Gcd only accepts two natural numbers (a, b >= 1).
// 0 or negative number causes panic.
// Gcd uses the Euclidean Algorithm.
func Gcd(a, b int) int {
	if a <= 0 || b <= 0 {
		panic(errors.New("[argument error]: Gcd only accepts two NATURAL numbers"))
	}
	if a < b {
		a, b = b, a
	}

	// Euclidean Algorithm
	for b > 0 {
		div := a % b
		a, b = b, div
	}

	return a
}

// Lcm returns the Least Common Multiple of two natural numbers.
// Lcd only accepts two natural numbers (a, b >= 1).
// 0 or negative number causes panic.
// Lcd uses the Euclidean Algorithm indirectly.
func Lcm(a, b int) int {
	if a <= 0 || b <= 0 {
		panic(errors.New("[argument error]: Gcd only accepts two NATURAL numbers"))
	}

	// a = a'*gcd, b = b'*gcd, a*b = a'*b'*gcd^2
	// a' and b' are relatively prime numbers
	// gcd consists of prime numbers, that are included in a and b
	gcd := Gcd(a, b)

	// not (a * b / gcd), because of reducing a probability of overflow
	return (a / gcd) * b
}

// Strtoi is a wrapper of `strconv.Atoi()`.
// If `strconv.Atoi()` returns an error, Strtoi calls panic.
func Strtoi(s string) int {
	if i, err := strconv.Atoi(s); err != nil {
		panic(errors.New("[argument error]: Strtoi only accepts integer string"))
	} else {
		return i
	}
}

// PrintIntsLine returns integers string delimited by a space.
func PrintIntsLine(A ...int) string {
	res := []rune{}

	for i := 0; i < len(A); i++ {
		str := strconv.Itoa(A[i])
		res = append(res, []rune(str)...)

		if i != len(A)-1 {
			res = append(res, ' ')
		}
	}

	return string(res)
}

/********** I/O usage **********/

//str := ReadString()
//i := ReadInt()
//X := ReadIntSlice(n)
//S := ReadRuneSlice()
//a := ReadFloat64()
//A := ReadFloat64Slice(n)

//str := ZeroPaddingRuneSlice(num, 32)
//str := PrintIntsLine(X...)

/*******************************************************************/

const MOD = 1000000000 + 7
const INF_INT64 = math.MaxInt64
const INF_BIT60 = 1 << 60

const ALPHABET_NUM = 26

var S []rune
var q int
var bits [ALPHABET_NUM]*BinaryIndexedTree

func main() {
	S = ReadRuneSlice()
	q = ReadInt()
	lenS := len(S)

	for i := 0; i < ALPHABET_NUM; i++ {
		bits[i] = NewBIT(lenS)
	}

	for i := 0; i < len(S); i++ {
		r := S[i]
		c := int(r - 'a')
		bits[c].Add(i+1, 1)
	}

	for i := 0; i < q; i++ {
		query := ReadInt()
		if query == 1 {
			idx := ReadInt()
			R := ReadRuneSlice()
			newc := R[0]
			newcint := int(newc - 'a')
			oldc := S[idx-1]
			oldcint := int(oldc - 'a')

			bits[newcint].Add(idx, 1)
			bits[oldcint].Add(idx, -1)
			S[idx-1] = newc
		} else {
			l, r := ReadInt2()
			res := 0
			for alpha := 0; alpha < ALPHABET_NUM; alpha++ {
				ss := bits[alpha].Sum(r) - bits[alpha].Sum(l-1)
				if ss > 0 {
					res++
				}
			}
			fmt.Println(res)
		}
	}
}

// Public methods
// bit := NewBIT(200000 + 5)
// s := bit.Sum(i) 						// Sum of [1, i] (1-based)
// bit.Add(i, x) 							// Add x to i (1-based)
// idx := bit.LowerBound(w) 	// minimum idx such that bit.Sum(idx) >= w

type BinaryIndexedTree struct {
	bit     []int
	n       int
	minPow2 int
}

// n(>=1) is number of elements of original data
func NewBIT(n int) *BinaryIndexedTree {
	newBit := new(BinaryIndexedTree)

	newBit.bit = make([]int, n+1)
	newBit.n = n

	newBit.minPow2 = 1
	for {
		if (newBit.minPow2 << 1) > n {
			break
		}
		newBit.minPow2 <<= 1
	}

	return newBit
}

// Sum of [1, i](1-based)
func (b *BinaryIndexedTree) Sum(i int) int {
	s := 0

	for i > 0 {
		s += b.bit[i]
		i -= i & (-i)
	}

	return s
}

// Add x to i(1-based)
func (b *BinaryIndexedTree) Add(i, x int) {
	for i <= b.n {
		b.bit[i] += x
		i += i & (-i)
	}
}

// LowerBound returns minimum i such that bit.Sum(i) >= w.
func (b *BinaryIndexedTree) LowerBound(w int) int {
	if w <= 0 {
		return 0
	}

	x := 0
	for k := b.minPow2; k > 0; k /= 2 {
		if x+k <= b.n && b.bit[x+k] < w {
			w -= b.bit[x+k]
			x += k
		}
	}

	return x + 1
}

package main

import (
	"bufio"
	"errors"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
)

/*********** I/O ***********/

var (
	// ReadString returns a WORD string.
	ReadString func() string
	stdout     *bufio.Writer
)

func init() {
	ReadString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	// r.Buffer(make([]byte, 1024), int(1e+11)) // for AtCoder
	r.Buffer(make([]byte, 1024), int(1e+9)) // for Codeforces
	// Split sets the split function for the Scanner. The default split function is ScanLines.
	// Split panics if it is called after scanning has started.
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

// ReadInt returns an integer.
func ReadInt() int {
	return int(readInt64())
}
func ReadInt2() (int, int) {
	return int(readInt64()), int(readInt64())
}
func ReadInt3() (int, int, int) {
	return int(readInt64()), int(readInt64()), int(readInt64())
}
func ReadInt4() (int, int, int, int) {
	return int(readInt64()), int(readInt64()), int(readInt64()), int(readInt64())
}

// ReadInt64 returns as integer as int64.
func ReadInt64() int64 {
	return readInt64()
}
func ReadInt64_2() (int64, int64) {
	return readInt64(), readInt64()
}
func ReadInt64_3() (int64, int64, int64) {
	return readInt64(), readInt64(), readInt64()
}
func ReadInt64_4() (int64, int64, int64, int64) {
	return readInt64(), readInt64(), readInt64(), readInt64()
}

func readInt64() int64 {
	i, err := strconv.ParseInt(ReadString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

// ReadIntSlice returns an integer slice that has n integers.
func ReadIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = ReadInt()
	}
	return b
}

// ReadInt64Slice returns as int64 slice that has n integers.
func ReadInt64Slice(n int) []int64 {
	b := make([]int64, n)
	for i := 0; i < n; i++ {
		b[i] = ReadInt64()
	}
	return b
}

// ReadFloat64 returns an float64.
func ReadFloat64() float64 {
	return float64(readFloat64())
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(ReadString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

// ReadFloatSlice returns an float64 slice that has n float64.
func ReadFloat64Slice(n int) []float64 {
	b := make([]float64, n)
	for i := 0; i < n; i++ {
		b[i] = ReadFloat64()
	}
	return b
}

// ReadRuneSlice returns a rune slice.
func ReadRuneSlice() []rune {
	return []rune(ReadString())
}

/*********** Debugging ***********/

// ZeroPaddingRuneSlice returns binary expressions of integer n with zero padding.
// For debugging use.
func ZeroPaddingRuneSlice(n, digitsNum int) []rune {
	sn := fmt.Sprintf("%b", n)

	residualLength := digitsNum - len(sn)
	if residualLength <= 0 {
		return []rune(sn)
	}

	zeros := make([]rune, residualLength)
	for i := 0; i < len(zeros); i++ {
		zeros[i] = '0'
	}

	res := []rune{}
	res = append(res, zeros...)
	res = append(res, []rune(sn)...)

	return res
}

/*********** DP sub-functions ***********/

// ChMin accepts a pointer of integer and a target value.
// If target value is SMALLER than the first argument,
//	then the first argument will be updated by the second argument.
func ChMin(updatedValue *int, target int) bool {
	if *updatedValue > target {
		*updatedValue = target
		return true
	}
	return false
}

// ChMax accepts a pointer of integer and a target value.
// If target value is LARGER than the first argument,
//	then the first argument will be updated by the second argument.
func ChMax(updatedValue *int, target int) bool {
	if *updatedValue < target {
		*updatedValue = target
		return true
	}
	return false
}

// NthBit returns nth bit value of an argument.
// n starts from 0.
func NthBit(num, nth int) int {
	return num >> uint(nth) & 1
}

// OnBit returns the integer that has nth ON bit.
// If an argument has nth ON bit, OnBit returns the argument.
func OnBit(num, nth int) int {
	return num | (1 << uint(nth))
}

// OffBit returns the integer that has nth OFF bit.
// If an argument has nth OFF bit, OffBit returns the argument.
func OffBit(num, nth int) int {
	return num & ^(1 << uint(nth))
}

// PopCount returns the number of ON bit of an argument.
func PopCount(num int) int {
	res := 0

	for i := 0; i < 70; i++ {
		if ((num >> uint(i)) & 1) == 1 {
			res++
		}
	}

	return res
}

/*********** Arithmetic ***********/

// Max returns the max integer among input set.
// This function needs at least 1 argument (no argument causes panic).
func Max(integers ...int) int {
	m := integers[0]
	for i, integer := range integers {
		if i == 0 {
			continue
		}
		if m < integer {
			m = integer
		}
	}
	return m
}

// Min returns the min integer among input set.
// This function needs at least 1 argument (no argument causes panic).
func Min(integers ...int) int {
	m := integers[0]
	for i, integer := range integers {
		if i == 0 {
			continue
		}
		if m > integer {
			m = integer
		}
	}
	return m
}

// DigitSum returns digit sum of a decimal number.
// DigitSum only accept a positive integer.
func DigitSum(n int) int {
	if n < 0 {
		return -1
	}

	res := 0

	for n > 0 {
		res += n % 10
		n /= 10
	}

	return res
}

// DigitNumOfDecimal returns digits number of n.
// n is non negative number.
func DigitNumOfDecimal(n int) int {
	res := 0

	for n > 0 {
		n /= 10
		res++
	}

	return res
}

// Sum returns multiple integers sum.
func Sum(integers ...int) int {
	s := 0

	for _, i := range integers {
		s += i
	}

	return s
}

// Kiriage returns Ceil(a/b)
// a >= 0, b > 0
func Kiriage(a, b int) int {
	return (a + (b - 1)) / b
}

// PowInt is integer version of math.Pow
// PowInt calculate a power by Binary Power (二分累乗法(O(log e))).
func PowInt(a, e int) int {
	if a < 0 || e < 0 {
		panic(errors.New("[argument error]: PowInt does not accept negative integers"))
	}

	if e == 0 {
		return 1
	}

	if e%2 == 0 {
		halfE := e / 2
		half := PowInt(a, halfE)
		return half * half
	}

	return a * PowInt(a, e-1)
}

// AbsInt is integer version of math.Abs
func AbsInt(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

// Gcd returns the Greatest Common Divisor of two natural numbers.
// Gcd only accepts two natural numbers (a, b >= 1).
// 0 or negative number causes panic.
// Gcd uses the Euclidean Algorithm.
func Gcd(a, b int) int {
	if a <= 0 || b <= 0 {
		panic(errors.New("[argument error]: Gcd only accepts two NATURAL numbers"))
	}
	if a < b {
		a, b = b, a
	}

	// Euclidean Algorithm
	for b > 0 {
		div := a % b
		a, b = b, div
	}

	return a
}

// Lcm returns the Least Common Multiple of two natural numbers.
// Lcd only accepts two natural numbers (a, b >= 1).
// 0 or negative number causes panic.
// Lcd uses the Euclidean Algorithm indirectly.
func Lcm(a, b int) int {
	if a <= 0 || b <= 0 {
		panic(errors.New("[argument error]: Gcd only accepts two NATURAL numbers"))
	}

	// a = a'*gcd, b = b'*gcd, a*b = a'*b'*gcd^2
	// a' and b' are relatively prime numbers
	// gcd consists of prime numbers, that are included in a and b
	gcd := Gcd(a, b)

	// not (a * b / gcd), because of reducing a probability of overflow
	return (a / gcd) * b
}

// Strtoi is a wrapper of `strconv.Atoi()`.
// If `strconv.Atoi()` returns an error, Strtoi calls panic.
func Strtoi(s string) int {
	if i, err := strconv.Atoi(s); err != nil {
		panic(errors.New("[argument error]: Strtoi only accepts integer string"))
	} else {
		return i
	}
}

// PrintIntsLine returns integers string delimited by a space.
func PrintIntsLine(A ...int) string {
	res := []rune{}

	for i := 0; i < len(A); i++ {
		str := strconv.Itoa(A[i])
		res = append(res, []rune(str)...)

		if i != len(A)-1 {
			res = append(res, ' ')
		}
	}

	return string(res)
}

/********** I/O usage **********/

//str := ReadString()
//i := ReadInt()
//X := ReadIntSlice(n)
//S := ReadRuneSlice()
//a := ReadFloat64()
//A := ReadFloat64Slice(n)

//str := ZeroPaddingRuneSlice(num, 32)
//str := PrintIntsLine(X...)

/*******************************************************************/

const MOD = 1000000000 + 7
const ALPHABET_NUM = 26
const INF_INT64 = math.MaxInt64
const INF_BIT60 = 1 << 60

var S []rune
var q int
var memo [26][100000 + 5]int

// [1, n]
var bit [26][100000 + 5]int
var lenS int

// var n int
// var A []int

func sum(i, alpha int) int {
	s := 0

	for i > 0 {
		s += bit[alpha][i]
		i -= i & (-i)
	}

	return s
}

func add(i, alpha, x int) {
	// for i <= n {
	for i <= lenS {
		bit[alpha][i] += x
		i += i & (-i)
	}
}

func main() {
	S = ReadRuneSlice()
	q = ReadInt()
	lenS = len(S)

	for i := 0; i < len(S); i++ {
		r := S[i]
		n := int(r - 'a')
		// for j := 0; j < ALPHABET_NUM; j++ {
		// 	if n == j {
		// 		memo[j][i+1] = memo[j][i] + 1
		// 	} else {
		// 		memo[j][i+1] = memo[j][i]
		// 	}
		// }
		add(i+1, n, 1)
	}

	for i := 0; i < q; i++ {
		query := ReadInt()
		if query == 1 {
			idx := ReadInt()
			R := ReadRuneSlice()
			c := R[0]
			cAlpha := int(c - 'a')
			oldc := S[idx-1]
			oldcAlpha := int(oldc - 'a')

			add(idx, cAlpha, 1)
			add(idx, oldcAlpha, -1)
			S[idx-1] = c
		} else {
			l, r := ReadInt2()
			res := 0
			for alpha := 0; alpha < ALPHABET_NUM; alpha++ {
				ss := sum(r, alpha) - sum(l-1, alpha)
				if ss > 0 {
					res++
				}
			}
			fmt.Println(res)
		}
	}
}

// type BinaryIndexedTree struct {
// 	bit []int
// 	n   int
// }

// func NewBIT(n int) *BinaryIndexedTree {
// 	newBit := new(BinaryIndexedTree)

// 	newBit.bit = make([]int, n+1)
// 	newBit.n = n

// 	return newBit
// }

// func (b *BinaryIndexedTree) Sum(i int) int {
// 	s := 0

// 	for i > 0 {
// 		s += b.bit[i]
// 		i -= i & (-i)
// 	}

// 	return s
// }

// func (b *BinaryIndexedTree) Add(i, x int) {
// 	for i <= b.n {
// 		b.bit[i] += x
// 		i += i & (-i)
// 	}
// }

// MODはとったか？
// 遷移だけじゃなくて最後の最後でちゃんと取れよ？

/*******************************************************************/

package main

import (
	"bufio"
	"errors"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
)

/*********** I/O ***********/

var (
	// ReadString returns a WORD string.
	ReadString func() string
	stdout     *bufio.Writer
)

func init() {
	ReadString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	// r.Buffer(make([]byte, 1024), int(1e+11)) // for AtCoder
	r.Buffer(make([]byte, 1024), int(1e+9)) // for Codeforces
	// Split sets the split function for the Scanner. The default split function is ScanLines.
	// Split panics if it is called after scanning has started.
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

// ReadInt returns an integer.
func ReadInt() int {
	return int(readInt64())
}
func ReadInt2() (int, int) {
	return int(readInt64()), int(readInt64())
}
func ReadInt3() (int, int, int) {
	return int(readInt64()), int(readInt64()), int(readInt64())
}
func ReadInt4() (int, int, int, int) {
	return int(readInt64()), int(readInt64()), int(readInt64()), int(readInt64())
}

// ReadInt64 returns as integer as int64.
func ReadInt64() int64 {
	return readInt64()
}
func ReadInt64_2() (int64, int64) {
	return readInt64(), readInt64()
}
func ReadInt64_3() (int64, int64, int64) {
	return readInt64(), readInt64(), readInt64()
}
func ReadInt64_4() (int64, int64, int64, int64) {
	return readInt64(), readInt64(), readInt64(), readInt64()
}

func readInt64() int64 {
	i, err := strconv.ParseInt(ReadString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

// ReadIntSlice returns an integer slice that has n integers.
func ReadIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = ReadInt()
	}
	return b
}

// ReadInt64Slice returns as int64 slice that has n integers.
func ReadInt64Slice(n int) []int64 {
	b := make([]int64, n)
	for i := 0; i < n; i++ {
		b[i] = ReadInt64()
	}
	return b
}

// ReadFloat64 returns an float64.
func ReadFloat64() float64 {
	return float64(readFloat64())
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(ReadString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

// ReadFloatSlice returns an float64 slice that has n float64.
func ReadFloat64Slice(n int) []float64 {
	b := make([]float64, n)
	for i := 0; i < n; i++ {
		b[i] = ReadFloat64()
	}
	return b
}

// ReadRuneSlice returns a rune slice.
func ReadRuneSlice() []rune {
	return []rune(ReadString())
}

/*********** Debugging ***********/

// ZeroPaddingRuneSlice returns binary expressions of integer n with zero padding.
// For debugging use.
func ZeroPaddingRuneSlice(n, digitsNum int) []rune {
	sn := fmt.Sprintf("%b", n)

	residualLength := digitsNum - len(sn)
	if residualLength <= 0 {
		return []rune(sn)
	}

	zeros := make([]rune, residualLength)
	for i := 0; i < len(zeros); i++ {
		zeros[i] = '0'
	}

	res := []rune{}
	res = append(res, zeros...)
	res = append(res, []rune(sn)...)

	return res
}

/*********** DP sub-functions ***********/

// ChMin accepts a pointer of integer and a target value.
// If target value is SMALLER than the first argument,
//	then the first argument will be updated by the second argument.
func ChMin(updatedValue *int, target int) bool {
	if *updatedValue > target {
		*updatedValue = target
		return true
	}
	return false
}

// ChMax accepts a pointer of integer and a target value.
// If target value is LARGER than the first argument,
//	then the first argument will be updated by the second argument.
func ChMax(updatedValue *int, target int) bool {
	if *updatedValue < target {
		*updatedValue = target
		return true
	}
	return false
}

// NthBit returns nth bit value of an argument.
// n starts from 0.
func NthBit(num, nth int) int {
	return num >> uint(nth) & 1
}

// OnBit returns the integer that has nth ON bit.
// If an argument has nth ON bit, OnBit returns the argument.
func OnBit(num, nth int) int {
	return num | (1 << uint(nth))
}

// OffBit returns the integer that has nth OFF bit.
// If an argument has nth OFF bit, OffBit returns the argument.
func OffBit(num, nth int) int {
	return num & ^(1 << uint(nth))
}

// PopCount returns the number of ON bit of an argument.
func PopCount(num int) int {
	res := 0

	for i := 0; i < 70; i++ {
		if ((num >> uint(i)) & 1) == 1 {
			res++
		}
	}

	return res
}

/*********** Arithmetic ***********/

// Max returns the max integer among input set.
// This function needs at least 1 argument (no argument causes panic).
func Max(integers ...int) int {
	m := integers[0]
	for i, integer := range integers {
		if i == 0 {
			continue
		}
		if m < integer {
			m = integer
		}
	}
	return m
}

// Min returns the min integer among input set.
// This function needs at least 1 argument (no argument causes panic).
func Min(integers ...int) int {
	m := integers[0]
	for i, integer := range integers {
		if i == 0 {
			continue
		}
		if m > integer {
			m = integer
		}
	}
	return m
}

// DigitSum returns digit sum of a decimal number.
// DigitSum only accept a positive integer.
func DigitSum(n int) int {
	if n < 0 {
		return -1
	}

	res := 0

	for n > 0 {
		res += n % 10
		n /= 10
	}

	return res
}

// DigitNumOfDecimal returns digits number of n.
// n is non negative number.
func DigitNumOfDecimal(n int) int {
	res := 0

	for n > 0 {
		n /= 10
		res++
	}

	return res
}

// Sum returns multiple integers sum.
func Sum(integers ...int) int {
	s := 0

	for _, i := range integers {
		s += i
	}

	return s
}

// Kiriage returns Ceil(a/b)
// a >= 0, b > 0
func Kiriage(a, b int) int {
	return (a + (b - 1)) / b
}

// PowInt is integer version of math.Pow
// PowInt calculate a power by Binary Power (二分累乗法(O(log e))).
func PowInt(a, e int) int {
	if a < 0 || e < 0 {
		panic(errors.New("[argument error]: PowInt does not accept negative integers"))
	}

	if e == 0 {
		return 1
	}

	if e%2 == 0 {
		halfE := e / 2
		half := PowInt(a, halfE)
		return half * half
	}

	return a * PowInt(a, e-1)
}

// AbsInt is integer version of math.Abs
func AbsInt(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

// Gcd returns the Greatest Common Divisor of two natural numbers.
// Gcd only accepts two natural numbers (a, b >= 1).
// 0 or negative number causes panic.
// Gcd uses the Euclidean Algorithm.
func Gcd(a, b int) int {
	if a <= 0 || b <= 0 {
		panic(errors.New("[argument error]: Gcd only accepts two NATURAL numbers"))
	}
	if a < b {
		a, b = b, a
	}

	// Euclidean Algorithm
	for b > 0 {
		div := a % b
		a, b = b, div
	}

	return a
}

// Lcm returns the Least Common Multiple of two natural numbers.
// Lcd only accepts two natural numbers (a, b >= 1).
// 0 or negative number causes panic.
// Lcd uses the Euclidean Algorithm indirectly.
func Lcm(a, b int) int {
	if a <= 0 || b <= 0 {
		panic(errors.New("[argument error]: Gcd only accepts two NATURAL numbers"))
	}

	// a = a'*gcd, b = b'*gcd, a*b = a'*b'*gcd^2
	// a' and b' are relatively prime numbers
	// gcd consists of prime numbers, that are included in a and b
	gcd := Gcd(a, b)

	// not (a * b / gcd), because of reducing a probability of overflow
	return (a / gcd) * b
}

// Strtoi is a wrapper of `strconv.Atoi()`.
// If `strconv.Atoi()` returns an error, Strtoi calls panic.
func Strtoi(s string) int {
	if i, err := strconv.Atoi(s); err != nil {
		panic(errors.New("[argument error]: Strtoi only accepts integer string"))
	} else {
		return i
	}
}

// PrintIntsLine returns integers string delimited by a space.
func PrintIntsLine(A ...int) string {
	res := []rune{}

	for i := 0; i < len(A); i++ {
		str := strconv.Itoa(A[i])
		res = append(res, []rune(str)...)

		if i != len(A)-1 {
			res = append(res, ' ')
		}
	}

	return string(res)
}

/********** I/O usage **********/

//str := ReadString()
//i := ReadInt()
//X := ReadIntSlice(n)
//S := ReadRuneSlice()
//a := ReadFloat64()
//A := ReadFloat64Slice(n)

//str := ZeroPaddingRuneSlice(num, 32)
//str := PrintIntsLine(X...)

/*******************************************************************/

const MOD = 1000000000 + 7
const INF_INT64 = math.MaxInt64
const INF_BIT60 = 1 << 60

const ALPHABET_NUM = 26

var S []rune
var q int
var bits [ALPHABET_NUM]*BinaryIndexedTree

func main() {
	S = ReadRuneSlice()
	q = ReadInt()
	lenS := len(S)

	for i := 0; i < ALPHABET_NUM; i++ {
		bits[i] = NewBIT(lenS)
	}

	for i := 0; i < len(S); i++ {
		r := S[i]
		c := int(r - 'a')
		bits[c].Add(i+1, 1)
	}

	for i := 0; i < q; i++ {
		query := ReadInt()
		if query == 1 {
			idx := ReadInt()
			R := ReadRuneSlice()
			newc := R[0]
			newcint := int(newc - 'a')
			oldc := S[idx-1]
			oldcint := int(oldc - 'a')

			bits[newcint].Add(idx, 1)
			bits[oldcint].Add(idx, -1)
			S[idx-1] = newc
		} else {
			l, r := ReadInt2()
			res := 0
			for alpha := 0; alpha < ALPHABET_NUM; alpha++ {
				ss := bits[alpha].Sum(r) - bits[alpha].Sum(l-1)
				if ss > 0 {
					res++
				}
			}
			fmt.Println(res)
		}
	}
}

type BinaryIndexedTree struct {
	bit []int
	n   int
}

func NewBIT(n int) *BinaryIndexedTree {
	newBit := new(BinaryIndexedTree)

	newBit.bit = make([]int, n+1)
	newBit.n = n

	return newBit
}

// Sum of [1, i]
func (b *BinaryIndexedTree) Sum(i int) int {
	s := 0

	for i > 0 {
		s += b.bit[i]
		i -= i & (-i)
	}

	return s
}

// Add x to i(1-based)
func (b *BinaryIndexedTree) Add(i, x int) {
	for i <= b.n {
		b.bit[i] += x
		i += i & (-i)
	}
}

// MODはとったか？
// 遷移だけじゃなくて最後の最後でちゃんと取れよ？

/*******************************************************************/

package main

import (
	"bufio"
	"errors"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
)

/*********** I/O ***********/

var (
	// ReadString returns a WORD string.
	ReadString func() string
	stdout     *bufio.Writer
)

func init() {
	ReadString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	// r.Buffer(make([]byte, 1024), int(1e+11)) // for AtCoder
	r.Buffer(make([]byte, 1024), int(1e+9)) // for Codeforces
	// Split sets the split function for the Scanner. The default split function is ScanLines.
	// Split panics if it is called after scanning has started.
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

// ReadInt returns an integer.
func ReadInt() int {
	return int(readInt64())
}
func ReadInt2() (int, int) {
	return int(readInt64()), int(readInt64())
}
func ReadInt3() (int, int, int) {
	return int(readInt64()), int(readInt64()), int(readInt64())
}
func ReadInt4() (int, int, int, int) {
	return int(readInt64()), int(readInt64()), int(readInt64()), int(readInt64())
}

// ReadInt64 returns as integer as int64.
func ReadInt64() int64 {
	return readInt64()
}
func ReadInt64_2() (int64, int64) {
	return readInt64(), readInt64()
}
func ReadInt64_3() (int64, int64, int64) {
	return readInt64(), readInt64(), readInt64()
}
func ReadInt64_4() (int64, int64, int64, int64) {
	return readInt64(), readInt64(), readInt64(), readInt64()
}

func readInt64() int64 {
	i, err := strconv.ParseInt(ReadString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

// ReadIntSlice returns an integer slice that has n integers.
func ReadIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = ReadInt()
	}
	return b
}

// ReadInt64Slice returns as int64 slice that has n integers.
func ReadInt64Slice(n int) []int64 {
	b := make([]int64, n)
	for i := 0; i < n; i++ {
		b[i] = ReadInt64()
	}
	return b
}

// ReadFloat64 returns an float64.
func ReadFloat64() float64 {
	return float64(readFloat64())
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(ReadString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

// ReadFloatSlice returns an float64 slice that has n float64.
func ReadFloat64Slice(n int) []float64 {
	b := make([]float64, n)
	for i := 0; i < n; i++ {
		b[i] = ReadFloat64()
	}
	return b
}

// ReadRuneSlice returns a rune slice.
func ReadRuneSlice() []rune {
	return []rune(ReadString())
}

/*********** Debugging ***********/

// ZeroPaddingRuneSlice returns binary expressions of integer n with zero padding.
// For debugging use.
func ZeroPaddingRuneSlice(n, digitsNum int) []rune {
	sn := fmt.Sprintf("%b", n)

	residualLength := digitsNum - len(sn)
	if residualLength <= 0 {
		return []rune(sn)
	}

	zeros := make([]rune, residualLength)
	for i := 0; i < len(zeros); i++ {
		zeros[i] = '0'
	}

	res := []rune{}
	res = append(res, zeros...)
	res = append(res, []rune(sn)...)

	return res
}

/*********** DP sub-functions ***********/

// ChMin accepts a pointer of integer and a target value.
// If target value is SMALLER than the first argument,
//	then the first argument will be updated by the second argument.
func ChMin(updatedValue *int, target int) bool {
	if *updatedValue > target {
		*updatedValue = target
		return true
	}
	return false
}

// ChMax accepts a pointer of integer and a target value.
// If target value is LARGER than the first argument,
//	then the first argument will be updated by the second argument.
func ChMax(updatedValue *int, target int) bool {
	if *updatedValue < target {
		*updatedValue = target
		return true
	}
	return false
}

// NthBit returns nth bit value of an argument.
// n starts from 0.
func NthBit(num, nth int) int {
	return num >> uint(nth) & 1
}

// OnBit returns the integer that has nth ON bit.
// If an argument has nth ON bit, OnBit returns the argument.
func OnBit(num, nth int) int {
	return num | (1 << uint(nth))
}

// OffBit returns the integer that has nth OFF bit.
// If an argument has nth OFF bit, OffBit returns the argument.
func OffBit(num, nth int) int {
	return num & ^(1 << uint(nth))
}

// PopCount returns the number of ON bit of an argument.
func PopCount(num int) int {
	res := 0

	for i := 0; i < 70; i++ {
		if ((num >> uint(i)) & 1) == 1 {
			res++
		}
	}

	return res
}

/*********** Arithmetic ***********/

// Max returns the max integer among input set.
// This function needs at least 1 argument (no argument causes panic).
func Max(integers ...int) int {
	m := integers[0]
	for i, integer := range integers {
		if i == 0 {
			continue
		}
		if m < integer {
			m = integer
		}
	}
	return m
}

// Min returns the min integer among input set.
// This function needs at least 1 argument (no argument causes panic).
func Min(integers ...int) int {
	m := integers[0]
	for i, integer := range integers {
		if i == 0 {
			continue
		}
		if m > integer {
			m = integer
		}
	}
	return m
}

// DigitSum returns digit sum of a decimal number.
// DigitSum only accept a positive integer.
func DigitSum(n int) int {
	if n < 0 {
		return -1
	}

	res := 0

	for n > 0 {
		res += n % 10
		n /= 10
	}

	return res
}

// DigitNumOfDecimal returns digits number of n.
// n is non negative number.
func DigitNumOfDecimal(n int) int {
	res := 0

	for n > 0 {
		n /= 10
		res++
	}

	return res
}

// Sum returns multiple integers sum.
func Sum(integers ...int) int {
	s := 0

	for _, i := range integers {
		s += i
	}

	return s
}

// Kiriage returns Ceil(a/b)
// a >= 0, b > 0
func Kiriage(a, b int) int {
	return (a + (b - 1)) / b
}

// PowInt is integer version of math.Pow
// PowInt calculate a power by Binary Power (二分累乗法(O(log e))).
func PowInt(a, e int) int {
	if a < 0 || e < 0 {
		panic(errors.New("[argument error]: PowInt does not accept negative integers"))
	}

	if e == 0 {
		return 1
	}

	if e%2 == 0 {
		halfE := e / 2
		half := PowInt(a, halfE)
		return half * half
	}

	return a * PowInt(a, e-1)
}

// AbsInt is integer version of math.Abs
func AbsInt(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

// Gcd returns the Greatest Common Divisor of two natural numbers.
// Gcd only accepts two natural numbers (a, b >= 1).
// 0 or negative number causes panic.
// Gcd uses the Euclidean Algorithm.
func Gcd(a, b int) int {
	if a <= 0 || b <= 0 {
		panic(errors.New("[argument error]: Gcd only accepts two NATURAL numbers"))
	}
	if a < b {
		a, b = b, a
	}

	// Euclidean Algorithm
	for b > 0 {
		div := a % b
		a, b = b, div
	}

	return a
}

// Lcm returns the Least Common Multiple of two natural numbers.
// Lcd only accepts two natural numbers (a, b >= 1).
// 0 or negative number causes panic.
// Lcd uses the Euclidean Algorithm indirectly.
func Lcm(a, b int) int {
	if a <= 0 || b <= 0 {
		panic(errors.New("[argument error]: Gcd only accepts two NATURAL numbers"))
	}

	// a = a'*gcd, b = b'*gcd, a*b = a'*b'*gcd^2
	// a' and b' are relatively prime numbers
	// gcd consists of prime numbers, that are included in a and b
	gcd := Gcd(a, b)

	// not (a * b / gcd), because of reducing a probability of overflow
	return (a / gcd) * b
}

// Strtoi is a wrapper of `strconv.Atoi()`.
// If `strconv.Atoi()` returns an error, Strtoi calls panic.
func Strtoi(s string) int {
	if i, err := strconv.Atoi(s); err != nil {
		panic(errors.New("[argument error]: Strtoi only accepts integer string"))
	} else {
		return i
	}
}

// PrintIntsLine returns integers string delimited by a space.
func PrintIntsLine(A ...int) string {
	res := []rune{}

	for i := 0; i < len(A); i++ {
		str := strconv.Itoa(A[i])
		res = append(res, []rune(str)...)

		if i != len(A)-1 {
			res = append(res, ' ')
		}
	}

	return string(res)
}

/********** I/O usage **********/

//str := ReadString()
//i := ReadInt()
//X := ReadIntSlice(n)
//S := ReadRuneSlice()
//a := ReadFloat64()
//A := ReadFloat64Slice(n)

//str := ZeroPaddingRuneSlice(num, 32)
//str := PrintIntsLine(X...)

/*******************************************************************/

const MOD = 1000000000 + 7
const INF_INT64 = math.MaxInt64
const INF_BIT60 = 1 << 60

const ALPHABET_NUM = 26

var S []rune
var q int

// [1, n]
var bit [ALPHABET_NUM][100000 + 5]int
var lenS int

func sum(i, alpha int) int {
	s := 0

	for i > 0 {
		s += bit[alpha][i]
		i -= i & (-i)
	}

	return s
}

func add(i, alpha, x int) {
	for i <= lenS {
		bit[alpha][i] += x
		i += i & (-i)
	}
}

func main() {
	S = ReadRuneSlice()
	q = ReadInt()
	lenS = len(S)

	for i := 0; i < len(S); i++ {
		r := S[i]
		c := int(r - 'a')
		add(i+1, c, 1)
	}

	for i := 0; i < q; i++ {
		query := ReadInt()
		if query == 1 {
			idx := ReadInt()
			R := ReadRuneSlice()
			newc := R[0]
			newcint := int(newc - 'a')
			oldc := S[idx-1]
			oldcint := int(oldc - 'a')

			add(idx, newcint, 1)
			add(idx, oldcint, -1)
			S[idx-1] = newc
		} else {
			l, r := ReadInt2()
			res := 0
			for alpha := 0; alpha < ALPHABET_NUM; alpha++ {
				ss := sum(r, alpha) - sum(l-1, alpha)
				if ss > 0 {
					res++
				}
			}
			fmt.Println(res)
		}
	}
}

// MODはとったか？
// 遷移だけじゃなくて最後の最後でちゃんと取れよ？

/*******************************************************************/

package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
	"strings"
)

func main() {
	f(os.Stdin, os.Stdout)
}

func f(in io.Reader, out io.Writer) {
	counters := make([]byte, 26)

	s := bufio.NewScanner(in)
	s.Buffer(make([]byte, 0, 100002), 100002)

	data := []byte(read(s))
	q, _ := strconv.Atoi(read(s))
	for i := 0; i < q; i += 1 {
		req := strings.Split(read(s), " ")
		switch req[0][0] {
		case '1':
			pos, _ := strconv.ParseUint(req[1], 10, 32)
			data[pos-1] = req[2][0]
		case '2':
			pos1, _ := strconv.ParseUint(req[1], 10, 32)
			pos2, _ := strconv.ParseUint(req[2], 10, 32)

			// Обнуляем все счетчики
			for j := range counters {
				counters[j] = 0
			}

			// Считаем кол-во каждого символа
			for _, c := range data[pos1-1 : pos2] {
				counters[c-'a'] += 1
			}

			// Считаем кол-во различных символов
			count := 0
			for _, c := range counters {
				if c > 0 {
					count += 1
				}
			}

			fmt.Fprintln(out, count)
		}
	}
}

func read(s *bufio.Scanner) string {
	s.Scan()
	return s.Text()
}

package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
	"strings"
)

var pc [256]byte

func init() {
	for i := range pc {
		pc[i] = pc[i/2] + byte(i&1)
	}
}

func PopCount(x uint32) int {
	return int(pc[byte(x)] +
		pc[byte(x>>8)] +
		pc[byte(x>>16)] +
		pc[byte(x>>24)])
}

func main() {
	f(os.Stdin, os.Stdout)
}

type Block struct {
	Mask  uint32
	Items []uint32
}

func (b *Block) SetItem(pos int, item uint32) {
	b.Items[pos] = item
	b.Mask = 0
	for _, item := range b.Items {
		b.Mask |= item
	}
}

func (b *Block) GetMask(pos1, pos2 int) uint32 {
	mask := uint32(0)
	for i := pos1; i < pos2; i += 1 {
		mask |= b.Items[i]
	}

	return mask
}

func f(in io.Reader, out io.Writer) {
	s := bufio.NewScanner(in)
	s.Buffer(make([]byte, 0, 100002), 100002)

	blockSize := 10
	blocks := make([]Block, 0)

	data := []byte(read(s))

	// Дополняем строку до длины блока
	sLen := len(data)
	z := 0
	if sLen < 8 {
		z = blockSize - sLen
	} else {
		z = blockSize - sLen%blockSize
	}
	data = append(data, make([]byte, z)...)

	// Разбиваем эл-ты на блоки
	for i := 0; i < len(data); i += blockSize {
		block := Block{
			Items: make([]uint32, blockSize),
		}
		for j := 0; j < blockSize; j += 1 {
			block.SetItem(j, 1<<(data[i+j]-'a'))
		}
		blocks = append(blocks, block)
	}

	q, _ := strconv.ParseUint(read(s), 10, 32)
	for i := 0; uint64(i) < q; i += 1 {
		req := strings.Split(read(s), " ")
		switch req[0][0] {
		case '1':
			pos, _ := strconv.ParseUint(req[1], 10, 64)
			n1 := (pos - 1) / uint64(blockSize)
			n2 := int(pos-1) % blockSize
			blocks[n1].SetItem(n2, 1<<(req[2][0]-'a'))
		case '2':
			pos1, _ := strconv.ParseUint(req[1], 10, 64)
			pos2, _ := strconv.ParseUint(req[2], 10, 64)

			n11 := (pos1 - 1) / uint64(blockSize)
			n12 := int(pos1-1) % blockSize
			n21 := (pos2) / uint64(blockSize)
			n22 := int(pos2) % blockSize

			counters := uint32(0)

			// Считаем биты крайних блоков
			if n11 == n21 {
				counters |= blocks[n11].GetMask(n12, n22)
			} else {
				counters |= blocks[n11].GetMask(n12, blockSize)
				counters |= blocks[n21].GetMask(0, n22)
				// считаем биты полных блоков
				for j := n11 + 1; j < n21-1; j++ {
					counters |= blocks[j].Mask
				}
			}

			_, _ = fmt.Fprintln(out, PopCount(counters))
		}
	}
}

func read(s *bufio.Scanner) string {
	s.Scan()
	return s.Text()
}

package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
	"strings"
)

func main() {
	f(os.Stdin, os.Stdout)
}

func f(in io.Reader, out io.Writer) {
	counters := make([]byte, 26)

	s := bufio.NewScanner(in)
	s.Buffer(make([]byte, 0, 100002), 100002)

	data := []byte(read(s))
	q, _ := strconv.Atoi(read(s))
	for i := 0; i < q; i += 1 {
		req := strings.Split(read(s), " ")
		switch req[0][0] {
		case '1':
			pos, _ := strconv.ParseUint(req[1], 10, 32)
			data[pos-1] = req[2][0]
		case '2':
			pos1, _ := strconv.ParseUint(req[1], 10, 32)
			pos2, _ := strconv.ParseUint(req[2], 10, 32)

			// Обнуляем все счетчики
			for i := range counters {
				counters[i] = 0
			}

			// Считаем кол-во каждого символа
			for _, c := range data[pos1-1 : pos2] {
				counters[c-'a'] += 1
			}

			// Считаем кол-во различных символов
			count := 0
			for _, c := range counters {
				if c > 0 {
					count += 1
				}
			}

			fmt.Fprintln(out, count)
		}
	}
}

func read(s *bufio.Scanner) string {
	s.Scan()
	return s.Text()
}

package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
	"strings"
)

func main() {
	f(os.Stdin, os.Stdout)
}

func f(in io.Reader, out io.Writer) {
	counters := make([]byte, 26)

	s := bufio.NewScanner(in)
	s.Buffer(make([]byte, 0, 100001), 100001)

	data := []byte(read(s))
	q, _ := strconv.Atoi(read(s))
	for i := 0; i < q; i += 1 {
		req := strings.Split(read(s), " ")
		switch req[0][0] {
		case '1':
			pos, _ := strconv.ParseUint(req[1], 10, 32)
			data[pos-1] = req[2][0]
		case '2':
			pos1, _ := strconv.ParseUint(req[1], 10, 32)
			pos2, _ := strconv.ParseUint(req[2], 10, 32)

			// Обнуляем все счетчики
			for i := range counters {
				counters[i] = 0
			}

			// Считаем кол-во каждого символа
			for _, c := range data[pos1-1 : pos2] {
				counters[c-'a'] += 1
			}

			// Считаем сколько различных символов
			count := 0
			for _, c := range counters {
				if c > 0 {
					count += 1
				}
			}

			fmt.Fprintln(out, count)
		}
	}
}

func read(s *bufio.Scanner) string {
	s.Scan()
	return s.Text()
}

package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
	"strings"
)

func main() {
	f(os.Stdin, os.Stdout)
}

func f(in io.Reader, out io.Writer) {
	counters := make([]byte, 256)

	s := bufio.NewScanner(in)
	s.Buffer(make([]byte, 0, 200*1024), 200*1024)

	data := []byte(read(s))
	q, _ := strconv.Atoi(read(s))
	for i := 0; i < q; i += 1 {
		req := strings.Split(read(s), " ")
		switch req[0][0] {
		case '1':
			pos, _ := strconv.ParseUint(req[1], 10, 32)
			data[pos-1] = req[2][0]
		case '2':
			pos1, _ := strconv.ParseUint(req[1], 10, 32)
			pos2, _ := strconv.ParseUint(req[2], 10, 32)

			// Обнуляем все счетчики
			for i := range counters {
				counters[i] = 0
			}

			// Считаем кол-во каждого символа
			for _, c := range data[pos1-1 : pos2] {
				counters[c] += 1
			}

			// Считаем сколько различных символов
			count := 0
			for _, c := range counters {
				if c > 0 {
					count += 1
				}
			}

			fmt.Fprintln(out, count)
		}
	}
}

func read(s *bufio.Scanner) string {
	s.Scan()
	return s.Text()
}

package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
	"strings"
)

func main() {
	f(os.Stdin, os.Stdout)
}

func f(in io.Reader, out io.Writer) {
	counters := make([]byte, 26)

	s := bufio.NewScanner(in)
	s.Buffer(make([]byte, 0, 1000002), 1000002)

	data := []byte(read(s))
	q, _ := strconv.Atoi(read(s))
	for i := 0; i < q; i += 1 {
		req := strings.Split(read(s), " ")
		switch req[0][0] {
		case '1':
			pos, _ := strconv.ParseUint(req[1], 10, 32)
			data[pos-1] = req[2][0]
		case '2':
			pos1, _ := strconv.ParseUint(req[1], 10, 32)
			pos2, _ := strconv.ParseUint(req[2], 10, 32)

			// Обнуляем все счетчики
			for j := range counters {
				counters[j] = 0
			}

			// Считаем кол-во каждого символа
			for _, c := range data[pos1-1 : pos2] {
				counters[c-'a'] += 1
			}

			// Считаем кол-во различных символов
			count := 0
			for _, c := range counters {
				if c > 0 {
					count += 1
				}
			}

			fmt.Fprintln(out, count)
		}
	}
}

func read(s *bufio.Scanner) string {
	s.Scan()
	return s.Text()
}


package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()

	var T int
	fmt.Fscan(in, &T)

	for t := 0; t < T; t++ {
		var n int
		var s2 string
		var s string
		fmt.Fscan(in, &n, &s2, &s)

		ch := rune(s2[0])
		var a int
		m := make([]bool, n+1)
		for i, v := range s {
			if ch == v {
				m[i+1] = true
				a++
			}
		}

		if a == n {
			fmt.Fprintln(out, 0)
		} else {
			var idx int
			for i := n; i >= 0; i-- {
				if m[i] {
					idx = i
					break
				}
			}

			if idx > n/2 {
				fmt.Fprintf(out, "1\n%d\n", idx)
			} else {
				fmt.Fprintf(out, "2\n%d %d\n", n, n-1)
			}
		}
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	const maxCapacity = 4096 * 1024
	buf := make([]byte, maxCapacity)
	scanner.Buffer(buf, maxCapacity)
	var (
		t int
	)
	scanner.Scan()
	t, _ = strconv.Atoi(scanner.Text())
	for i := 0; i < t; i++ {
		flag := false
		scanner.Scan()
		n, _ := strconv.Atoi(scanner.Text()[:strings.Index(scanner.Text(), " ")])
		b := scanner.Text()[strings.Index(scanner.Text(), " ")+1:]
		scanner.Scan()
		l := scanner.Text()
		if strings.Count(l, b) == n {
			fmt.Println(0)
		} else {
			for i := len(l) / 2; i < len(l); i++ {
				if string(l[i]) == b {
					flag = true
					fmt.Println("1")
					fmt.Println(i + 1)
					break
				}
			}
			if !flag {
				fmt.Println("2")
				fmt.Println(len(l), len(l)-1)
			}
		}
	}
}

package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"time"
)

// var m []int
// err = json.Unmarshal([]byte(r.FormValue("example")), &m)

// for i := 0; i < len(m); i++ {
// 	fmt.Println(m[i])
// }

// sort.Slice(arr, func(i, j int) bool {
// 	return arr[i] > arr[j]
// })

func MIN(x, y int64) int64 {
	if x > y {
		return y
	} else {
		return x
	}
}

func MINN(x, y int) int {
	if x > y {
		return y
	} else {
		return x
	}
}

func MKO(x, y int64) int64 {
	if x < y {
		return 0
	} else {
		return x - y + 1
	}
}

func MAX(x, y int64) int64 {
	if x > y {
		return x
	} else {
		return y
	}
}

func MAXX(x, y int) int {
	if x > y {
		return x
	} else {
		return y
	}
}

func LCM(x, y int) int {
	if x >= y {
		initial := x
		for i := 1; i < y+2; i++ {
			if initial%y == 0 {
				break
			} else {
				initial = initial + x
			}

		}
		return initial
	} else {
		initial := y
		for i := 1; i < x+2; i++ {
			if initial%x == 0 {
				break
			} else {
				initial = initial + y
			}

		}
		return initial
	}
}

func GCD(x, y int64) int64 {
	if x*y == 0 {
		return MAX(x, y)
	} else {
		var l, q int64
		l = MAX(x, y)
		q = MIN(x, y)
		var m int64
		for l*q > 0 {
			a := l % q
			b := l - a
			cc := int64(b / q)
			remain := l - cc*q
			l = MAX(remain, q)
			q = MIN(remain, q)
			if l*q == 0 {
				m = l + q
				break
			}

		}
		return m
	}
}

func IsItPrime(x int) bool {
	if x < 10 {
		if x == 2 || x == 3 || x == 5 || x == 7 {
			return true
		} else {
			return false
		}
	} else {
		j := 0
		k := math.Sqrt(float64(x))
		for m := 3; m <= int(k); {
			if x%m == 0 {
				j = 1
				break
			}
			m = m + 2
		}
		if j == 1 {
			return false
		} else {
			return true
		}
	}
}

func PrimeFactorization(n int) (pfs map[int]int) {
	pfs = make(map[int]int)

	// Get the number of 2s that divide n
	for n%2 == 0 {
		if _, ok := pfs[2]; ok {
			pfs[2] += 1
		} else {
			pfs[2] = 1
		}
		n = n / 2
	}

	// n must be odd at this point. so we can skip one element
	// (note i = i + 2)
	for i := 3; i*i <= n; i = i + 2 {
		// while i divides n, append i and divide n
		for n%i == 0 {
			if _, ok := pfs[i]; ok {
				pfs[i] += 1
			} else {
				pfs[i] = 1
			}
			n = n / i
		}
	}

	// This condition is to handle the case when n is a prime number
	// greater than 2
	if n > 2 {
		pfs[n] = 1
	}

	return
}

func NumberOfDivisors(n int) int {
	pfs := PrimeFactorization(n)

	num := 1
	for _, exponents := range pfs {
		num *= (exponents + 1)
	}

	return num
}

func KthPrime(x int) (y int) {
	if x == 1 {
		y = 2
	}
	if x == 2 {
		y = 3
	}
	if x > 2 {
		var sum int = 2
		begin := 5
		for sum < x+1 {
			if IsItPrime(begin) == true {
				sum++
			}
			if sum == x {
				y = begin
				break
			} else {
				if begin%6 == 1 {
					begin = begin + 4
				} else {
					begin = begin + 2
				}
			}
		}
	}
	return
}

func MODULE(x, y int) int {
	if x > y {
		return x - y
	} else {
		return y - x
	}
}

func BITAND(x, y int64) int64 {
	var ans int64
	begin := x
	sec := y
	var count int64 = 1
	for 1 == 1 {
		if (begin%2)*(sec%2) == 1 {
			ans = ans + count
			count = count * 2
			begin = int64(begin / 2)
			sec = int64(sec / 2)
			if begin*sec == 0 {
				break
			}

		} else {
			count = count * 2
			begin = int64(begin / 2)
			sec = int64(sec / 2)
			if begin*sec == 0 {
				break
			}
		}
	}
	return ans
}

func Sum(n, m int) int {
	var ans int

	if n == 1 {
		return 0
	} else {
		for i := 2; i < n; i++ {
			ans = (ans + Sum(i, m)) % m
		}
		for j := 2; j < n+1; j++ {
			ans = (ans + Sum(n/j, m)) % m
		}
		return ans
	}
}

func ChangeStringToDate(x string) (t time.Time, err error) {
	t, err = time.Parse("2006-01-02", x)
	return
}

func DiffrenceBetweenTwoDates(first, second time.Time) int64 {
	date := first
	date2 := second
	k := date.Unix() - date2.Unix()
	return k
}

var t int

func main() {
	var input io.Reader = bufio.NewReader(os.Stdin)
	fmt.Fscan(input, &t)

	for o := 0; o < t; o++ {
		var n int
		var c string

		fmt.Fscan(input, &n, &c)

		STRING := make([]byte, 0)
		fmt.Fscan(input, &STRING)

		ARR := make([]int, 0)
		BRR := make([]int, 0)
		for i := 0; i < n; i++ {
			if string(STRING[i]) != c {
				ARR = append(ARR, i+1)
			} else {
				BRR = append(BRR, i+1)
			}
		}

		q := len(ARR)
		sec := len(BRR)

		if q == 0 {
			fmt.Println(0)
		} else {
			qqq := 0
			for i := sec - 1; i >= 0; i-- {
				init := 0
				for j := q - 1; j >= 0; j-- {
					if ARR[j] < BRR[i] {
						break
					} else {
						if ARR[j]%BRR[i] == 0 {
							init = 1
							break
						}
					}
				}
				if init == 0 {
					qqq = BRR[i]
					break
				}

			}
			if qqq > 0 {
				fmt.Println(1)
				fmt.Println(qqq)
			} else {
				fmt.Println(2)
				fmt.Println(ARR[q-1])
				if ARR[q-1] > 2 {
					fmt.Println(ARR[q-1] - 1)
				} else {
					fmt.Println(n)
				}

			}

		}
	}

}

package main

import (
	"bufio"
	."fmt"
	"io"
	"os"
	"strings"
)

// github.com/EndlessCheng/codeforces-go
func CF1594C(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	var T, n int
	var s, ch string
O:
	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &n, &ch, &s)
		if strings.Count(s, ch) == n {
			Fprintln(out, 0)
			continue
		}
	o:
		for i := 1; i <= n; i++ {
			for j := i; j <= n; j += i {
				if s[j-1] != ch[0] {
					continue o
				}
			}
			Fprintln(out, 1)
			Fprintln(out, i)
			continue O
		}
		Fprintln(out, 2)
		Fprintln(out, n, n-1)
	}
}

func main() { CF1594C(os.Stdin, os.Stdout) }

package main

import (
	"bufio"
	. "fmt"
	"io"
	"os"
	"strings"
)

// github.com/EndlessCheng/codeforces-go
func CF1594C(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	var T, n int
	var s, ch string
O:
	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &n, &ch, &s)
		if strings.Count(s, ch) == n {
			Fprintln(out, 0)
			continue
		}
	o:
		for i := 1; i <= n; i++ {
			for j := i; j <= n; j += i {
				if s[j-1] != ch[0] {
					continue o
				}
			}
			Fprintln(out, 1)
			Fprintln(out, i)
			continue O
		}
		Fprintln(out, 2)
		Fprintln(out, n, n-1)
	}
}

func main() { CF1594C(os.Stdin, os.Stdout) }

package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	r := bufio.NewReaderSize(os.Stdin, 1024*1024)

	var T int
	fmt.Fscanf(r, "%d\n", &T)
	for t := 0; t < T; t++ {
		var n int
		var cs string

		fmt.Fscanf(r, "%d %s\n", &n, &cs)

		var s string
		fmt.Fscanf(r, "%s\n", &s)

		c := cs[0]

		i := 0
		for ; i < n; i++ {
			if s[i] != c {
				break
			}
		}

		if i == n {
			fmt.Println(0)
			continue
		}

		i = 2
		for ; i <= n; i++ {
			j := i
			for ; j <= n; j += i {
				if s[j-1] != c {
					break
				}
			}
			if j > n {
				fmt.Println(1)
				fmt.Println(i)
				break
			}
		}

		if i == n+1 {
			fmt.Println(2)
			fmt.Println(n-1, n)
		}
	}
}

package main

import (
	"fmt"
)

func solve() {
	var n int
	_, _ = fmt.Scan(&n)
	var c byte
	_, _ = fmt.Scanf("%c", &c)
	var s string
	_, _ = fmt.Scan(&s)
	var cnt = 0
	for i := 0; i < n; i++ {
		if byte(s[i]) != c {
			cnt++
		}
	}
	if cnt == 0 {
		fmt.Println(0)
		return
	}

	for i := 1; i <= n; i++ {
		var tmp = 0
		for j := i; j <= n; j += i {
			if s[j-1] != c {
				tmp++
			}
		}
		if tmp == 0 {
			fmt.Println(1)
			fmt.Println(i)
			return
		}
	}

	fmt.Println(2)
	num := n - 1
	if n&1 == 1 {
		num++
	}
	fmt.Printf("2 %v\n", num)

}

func main() {
	var t int = 0
	_, _ = fmt.Scan(&t)
	for ; t > 0; t-- {
		solve()
	}
}

package main

import(
	"fmt"
)
const mod =1e9+7
var t,n int
var s string
var c string

func nhap(){
	fmt.Scan(&n)
	fmt.Scan(&c)
	fmt.Scan(&s)
}
func lam(){
	ans:=-1
	oke:=true
	for i:=0;i<n;i++{
		if s[i]==c[0]{
			ans=i+1
		}else{
			oke=false
		}
	}
	if oke==true{
		fmt.Println(0)
		return
	}else{
		if 2*ans>n{
			fmt.Println(1)
			fmt.Println(ans)
		}else{
			fmt.Println(2)
			fmt.Println(n-1,n)
		}
	}
}
func main() {
	fmt.Scan(&t)
	for t>0{
		t--
		nhap()
		lam()
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

var (
	writer  = bufio.NewWriter(os.Stdout)
	scanner = bufio.NewScanner(os.Stdin)
)

func init() {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 4096), 1e9)
}

func printf(f string, a ...interface{}) {
	fmt.Fprintf(writer, f, a...)
}

func _int() int {
	s := _string()
	i := 0
	if s[0] == '-' {
		for _, r := range s[1:] {
			i *= 10
			i -= int(r - '0')
		}
		return i
	}
	for _, r := range s {
		i *= 10
		i += int(r - '0')
	}
	return i
}

func _int64() int64 {
	s := _string()
	i := int64(0)
	if s[0] == '-' {
		for _, r := range s[1:] {
			i *= 10
			i -= int64(r - '0')
		}
		return i
	}
	for _, r := range s {
		i *= 10
		i += int64(r - '0')
	}
	return i
}

func _string() string {
	if !scanner.Scan() {
		panic(scanner.Err())
	}
	return scanner.Text()
}

func main() {
	defer writer.Flush()
	for t := _int(); t > 0; t-- {
		n := _int64()
		c := _string()[0]
		s := _string()
		res := sol(n, c, s)
		printf("%d\n", len(res))
		if len(res) > 0 {
			for _, r := range res {
				printf("%d ", r)
			}
			printf("\n")
		}
	}
}

func sol(n int64, c byte, s string) []int64 {
	if allC(s, c) {
		return nil
	}
	for i := n - 1; i >= 0; i-- {
		if s[i] == c {
			if (i+1)*2 > n {
				return []int64{i + 1}
			}
			break
		}
	}
	return []int64{n - 1, n}
}

func allC(s string, c byte) bool {
	for i := range s {
		if s[i] != c {
			return false
		}
	}
	return true
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

func main()  {
	in := bufio.NewReader(os.Stdin)
	//out := bufio.NewWriter(os.Stdout)
	var t int
	var n int64
	fmt.Fscanf(in, "%d\n", &t)
	for i:= 0;i < t;i++{
		tchar := make([]byte,2)
		str := make([]byte,30010)
		fmt.Fscanf(in, "%d %s\n", &n,&tchar)
		fmt.Fscanf(in,"%s\n",&str)
		strlen := len(str)
		last := -1
		tcharCnt := 0
		for j:= strlen-1;j >= 0;j--{
			if str[j] == tchar[0]{
				tcharCnt++
				if last == -1{
					last = j
				}
			}
		}
		if tcharCnt == strlen{
			fmt.Printf("0\n")
			continue
		}
		if last+1 > strlen/2{
			fmt.Printf("1\n")
			fmt.Printf("%v\n",last+1)
		}else{
			fmt.Printf("2\n")
			fmt.Printf("%v %v\n",strlen,strlen-1)
		}
	}

}

package main

import (
	"bufio"
	"fmt"
	"os"
	"sync"
	"runtime"
	"math"
)

var N int
var char string

const MOD int64 = 1000000007

var a string

var primes []uint64
var mp map[int]bool

func main() {

	r := bufio.NewReader(os.Stdin)

	var t int

	fmt.Fscan(r, &t)

	for i := 0; i < t; i++ {
		fmt.Fscan(r, &N, &char)

		fmt.Fscan(r, &a)

		solve()
	}
}

func solve() {
	//1
	diff := make(map[int]bool)
	for i := 0; i < N; i++ {
		if string(a[i]) != char {
			diff[i + 1] = true
		}
	}

	if len(diff) == 0 {
		fmt.Println(0)
		return
	}

	for i := N - 1; i >=0 ; i-- {
		if string(a[i]) == char {

			present := false

			for j := 1; ; j++{
				pos := (i + 1) * j

				if pos > N {
					break
				}

				if ok, _ := diff[(i + 1) * j]; ok {
					present = true
					break
				}
			}

			if !present {
				fmt.Println(1)
				fmt.Println(i + 1)
				return
			}

		}
	}

	fmt.Println(2)
	fmt.Print(N)
	fmt.Print(" ")
	fmt.Print(N - 1)
	fmt.Println()
}

func GCD(a, b int) int {
	for b != 0 {
		t := b
		b = a % b
		a = t
	}
	return a
}

func fill(nums []bool, i uint64, max uint64) {
	a := 3 * i
	for a <= max {
		nums[a/2] = true
		a = a + 2*i
	}
}

func goFill(nums []bool, i uint64, max uint64, next chan bool) {
	fill(nums, i, max)
	<-next
}

// SieveOfEratosthenes returns a slice of all prime numbers equal or lower than max using Sieve Of Eratosthenes.
// This is without segmenting.
func SieveOfEratosthenes(n uint64) []uint64 {
	cores := runtime.NumCPU()
	next := make(chan bool, cores)

	var nums = make([]bool, n/2+1)
	m := uint64(math.Sqrt(float64(n)))

	for i := uint64(3); i <= m; i = i + 2 {
		if nums[i/2] == false {
			go goFill(nums, i, n, next)
			next <- true
		}
	}

	for i := 0; i < cores; i++ {
		next <- true
	}

	var ps []uint64
	if n >= 2 {
		ps = append(ps, 2)
	}
	for i := uint64(3); i <= n; i = i + 2 {
		if nums[i/2] == false {
			ps = append(ps, i)
		}
	}
	return ps
}

var csegPool sync.Pool

func fillSegments(n uint64, basePrimes []uint64, allPrimes *[]uint64, segSize uint64, segNum uint64, next chan bool, nextTurn []chan bool) {
	cseg := (csegPool.Get()).([]bool)
	for i := uint64(0); i < segSize; i++ {
		cseg[i] = false
	}
	for i := 0; i < len(basePrimes); i++ {
		jMax := segSize * (segNum + 1) / basePrimes[i]
		for j := (segSize * segNum) / basePrimes[i]; j < jMax; j++ {
			sn := (j + 1) * basePrimes[i]
			cseg[sn-segSize*segNum-1] = true
		}
	}

	// This waiting for turn is to avoid sorts at the end.
	// Sorts are much more expensive than this wait even for a
	// mostly sorted list.
	if segNum > 1 {
		<-nextTurn[segNum]
	}

	for i := uint64(0); i < segSize; i++ {
		if !cseg[i] && segSize*segNum+i+1 <= n {
			*allPrimes = append(*allPrimes, segSize*segNum+i+1)
		}
	}

	<-next
	if int(segNum)+1 < len(nextTurn) {
		nextTurn[segNum+1] <- true
	}

	csegPool.Put(cseg)
}

// Primes is using Segmented sieve. This method will reduce memory usae of Sieve of Eratosthenes considerably.
// besides memory allocation for Prime numbers slice, there is only O(sqrt(n)) extra memory required for the operation
// You can learn more about it in https://en.wikipedia.org/wiki/Sieve_of_Eratosthenes.
func Primes(n uint64) (allPrimes []uint64) {
	if uint64(math.Log(float64(n))-1) == 0 {
		return SieveOfEratosthenes(n)
	}

	// There is a function pi(x) in math that will returns approximate number of prime numbers below n.
	allPrimes = make([]uint64, 0, n/uint64(math.Log(float64(n))-1))
	segSize := uint64(math.Sqrt(float64(n)))

	csegPool.New = func() interface{} {
		return make([]bool, segSize)
	}

	basePrimes := SieveOfEratosthenes(segSize)
	allPrimes = append(allPrimes, basePrimes...)

	cores := runtime.NumCPU()
	next := make(chan bool, cores)
	var nextTurn []chan bool
	nextTurn = make([]chan bool, n/segSize+1)
	for i := uint64(0); i < n/segSize+1; i++ {
		nextTurn[i] = make(chan bool)
	}
	for segNum := uint64(1); segNum <= n/segSize; segNum++ {
		go fillSegments(n, basePrimes, &allPrimes, segSize, segNum, next, nextTurn)
		next <- true
	}
	for i := 0; i < cores; i++ {
		next <- true
	}

	return allPrimes
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	var (
		t int
	)
	scanner.Scan()
	t, _ = strconv.Atoi(scanner.Text())
	for i := 0; i < t; i++ {
		flag := false
		scanner.Scan()
		n, _ := strconv.Atoi(scanner.Text()[:strings.Index(scanner.Text(), " ")])
		b := scanner.Text()[strings.Index(scanner.Text(), " ")+1:]
		scanner.Scan()
		l := scanner.Text()
		if strings.Count(l, b) == n {
			fmt.Println(0)
		} else {
			for i := len(l) / 2; i < len(l); i++ {
				if string(l[i]) == b {
					flag = true
					fmt.Println("1")
					fmt.Println(i + 1)
					break
				}
			}
			if !flag {
				fmt.Println("2")
				fmt.Println(len(l), len(l)-1)
			}
		}
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	var (
		t int
	)
	scanner.Scan()
	t, _ = strconv.Atoi(scanner.Text())
	for i := 0; i < t; i++ {
		flag := false
		scanner.Scan()
		b := scanner.Text()[strings.Index(scanner.Text(), " ")+1:]
		scanner.Scan()
		l := scanner.Text()
		if strings.Count(l, b) == len(l) {
			fmt.Println(0)
		} else {
			for i := len(l) / 2; i < len(l); i++ {
				if string(l[i]) == b {
					flag = true
					fmt.Println("1")
					fmt.Println(i + 1)
					break
				}
			}
			if !flag {
				fmt.Println("2")
				fmt.Println(len(l), len(l)-1)
			}
		}
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	var (
		t int
	)
	scanner.Scan()
	t, _ = strconv.Atoi(scanner.Text())
	for i := 0; i < t; i++ {
		evenFlag := false
		oddFlag := false
		scanner.Scan()
		b := scanner.Text()[strings.Index(scanner.Text(), " ")+1:]
		scanner.Scan()
		l := scanner.Text()
		for i := range l {
			if string(l[i]) != b && i > 0 {
				if i%2 == 0 {
					evenFlag = true
				} else {
					oddFlag = true
				}
			}
		}
		if string(l[0]) != b && !(evenFlag || oddFlag) {
			evenFlag = true
		}
		if evenFlag && oddFlag {
			fmt.Println("2")
			fmt.Println(len(l), len(l)-1)
		} else if evenFlag {
			fmt.Println("1")
			fmt.Println("2")
		} else if oddFlag {
			fmt.Println("1")
			fmt.Println("3")
		} else {
			fmt.Println("0")
		}
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	var (
		t int
	)
	scanner.Scan()
	t, _ = strconv.Atoi(scanner.Text())
	for i := 0; i < t; i++ {
		evenFlag := false
		oddFlag := false
		scanner.Scan()
		b := scanner.Text()[strings.Index(scanner.Text(), " ")+1:]
		scanner.Scan()
		l := scanner.Text()
		for i := range l {
			if string(l[i]) != b && i > 0 {
				if i%2 == 0 {
					evenFlag = true
				} else {
					oddFlag = true
				}
			}
		}
		if string(l[0]) != b && !(evenFlag || oddFlag) {
			evenFlag = true
		}
		if evenFlag && oddFlag {
			fmt.Println("2")
			fmt.Println("2 3")
		} else if evenFlag {
			fmt.Println("1")
			fmt.Println("2")
		} else if oddFlag {
			fmt.Println("1")
			fmt.Println("3")
		} else {
			fmt.Println("0")
		}
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	var (
		t int
	)
	scanner.Scan()
	t, _ = strconv.Atoi(scanner.Text())
	for i := 0; i < t; i++ {
		evenFlag := false
		oddFlag := false
		scanner.Scan()
		b := scanner.Text()[strings.Index(scanner.Text(), " ")+1:]
		scanner.Scan()
		l := scanner.Text()
		for i := range l {
			if string(l[i]) != b && i > 0 {
				if i%2 == 0 {
					oddFlag = true
				} else {
					evenFlag = true
				}
			}
		}
		if string(l[0]) != b && !(evenFlag || oddFlag) {
			evenFlag = true
		}
		if evenFlag && oddFlag {
			fmt.Println("2")
			fmt.Println("2 3")
		} else if evenFlag {
			fmt.Println("1")
			fmt.Println("2")
		} else if oddFlag {
			fmt.Println("1")
			fmt.Println("3")
		} else {
			fmt.Println("0")
		}
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	var (
		t int
	)
	scanner.Scan()
	t, _ = strconv.Atoi(scanner.Text())
	for i := 0; i < t; i++ {
		evenFlag := false
		oddFlag := false
		scanner.Scan()
		b := scanner.Text()[strings.Index(scanner.Text(), " ")+1:]
		scanner.Scan()
		l := scanner.Text()
		for i := range l {
			if string(l[i]) != b && i > 0 {
				if i%2 == 0 {
					evenFlag = true
				} else {
					oddFlag = true
				}
			}
		}
		if string(l[0]) != b {
			evenFlag = true
		}
		if evenFlag && oddFlag {
			fmt.Println("2")
			fmt.Println("2 3")
		} else if evenFlag {
			fmt.Println("1")
			fmt.Println("2")
		} else if oddFlag {
			fmt.Println("1")
			fmt.Println("3")
		} else {
			fmt.Println("0")
		}
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	var (
		t int
	)
	scanner.Scan()
	t, _ = strconv.Atoi(scanner.Text())
	for i := 0; i < t; i++ {
		evenFlag := false
		oddFlag := false
		scanner.Scan()
		b := scanner.Text()[strings.Index(scanner.Text(), " ")+1:]
		scanner.Scan()
		l := scanner.Text()
		for i := range l {
			if string(l[i]) != b && i > 0 {
				if i%2 == 0 {
					oddFlag = true
				} else {
					evenFlag = true
				}
			}
		}
		if string(l[0]) != b {
			evenFlag = true
		}
		if evenFlag && oddFlag {
			fmt.Println("2")
			fmt.Println("2 3")
		} else if evenFlag {
			fmt.Println("1")
			fmt.Println("2")
		} else if oddFlag {
			fmt.Println("1")
			fmt.Println("3")
		} else {
			fmt.Println("0")
		}
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	var (
		t int
	)
	scanner.Scan()
	t, _ = strconv.Atoi(scanner.Text())
	for i := 0; i < t; i++ {
		evenFlag := false
		oddFlag := false
		scanner.Scan()
		b := scanner.Text()[strings.Index(scanner.Text(), " ") + 1:]
		scanner.Scan()
		l := scanner.Text()
		for i := range l {
			if string(l[i]) != b {
				if i%2 == 0 {
					evenFlag = true
				} else {
					oddFlag = true
				}
			}
		}
		if evenFlag && oddFlag {
			fmt.Println("2")
			fmt.Println("2 3")
		} else if evenFlag {
			fmt.Println("1")
			fmt.Println("2")
		} else if oddFlag {
			fmt.Println("1")
			fmt.Println("3")
		} else {
			fmt.Println("0")
		}
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	var (
		a, t int
		b, l string
	)
	scanner.Scan()
	t, _ = strconv.Atoi(scanner.Text())
	for i := 0; i < t; i++ {
		evenFlag := false
		oddFlag := false
		fmt.Scanln(&a, &b)
		fmt.Scanln(&l)
		for i := range l {
			if string(l[i]) != (b) {
				if i%2 == 0 {
					evenFlag = true
				} else {
					oddFlag = true
				}
			}
		}
		if evenFlag && oddFlag {
			fmt.Println("2")
			fmt.Println("2 3")
		} else if evenFlag {
			fmt.Println("1")
			fmt.Println("2")
		} else if oddFlag {
			fmt.Println("1")
			fmt.Println("3")
		} else {
			fmt.Println("0")
		}
	}
}

package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"time"
)

// var m []int
// err = json.Unmarshal([]byte(r.FormValue("example")), &m)

// for i := 0; i < len(m); i++ {
// 	fmt.Println(m[i])
// }

// sort.Slice(arr, func(i, j int) bool {
// 	return arr[i] > arr[j]
// })

func MIN(x, y int64) int64 {
	if x > y {
		return y
	} else {
		return x
	}
}

func MINN(x, y int) int {
	if x > y {
		return y
	} else {
		return x
	}
}

func MKO(x, y int64) int64 {
	if x < y {
		return 0
	} else {
		return x - y + 1
	}
}

func MAX(x, y int64) int64 {
	if x > y {
		return x
	} else {
		return y
	}
}

func MAXX(x, y int) int {
	if x > y {
		return x
	} else {
		return y
	}
}

func LCM(x, y int) int {
	if x >= y {
		initial := x
		for i := 1; i < y+2; i++ {
			if initial%y == 0 {
				break
			} else {
				initial = initial + x
			}

		}
		return initial
	} else {
		initial := y
		for i := 1; i < x+2; i++ {
			if initial%x == 0 {
				break
			} else {
				initial = initial + y
			}

		}
		return initial
	}
}

func GCD(x, y int64) int64 {
	if x*y == 0 {
		return MAX(x, y)
	} else {
		var l, q int64
		l = MAX(x, y)
		q = MIN(x, y)
		var m int64
		for l*q > 0 {
			a := l % q
			b := l - a
			cc := int64(b / q)
			remain := l - cc*q
			l = MAX(remain, q)
			q = MIN(remain, q)
			if l*q == 0 {
				m = l + q
				break
			}

		}
		return m
	}
}

func IsItPrime(x int) bool {
	if x < 10 {
		if x == 2 || x == 3 || x == 5 || x == 7 {
			return true
		} else {
			return false
		}
	} else {
		j := 0
		k := math.Sqrt(float64(x))
		for m := 3; m <= int(k); {
			if x%m == 0 {
				j = 1
				break
			}
			m = m + 2
		}
		if j == 1 {
			return false
		} else {
			return true
		}
	}
}

func PrimeFactorization(n int) (pfs map[int]int) {
	pfs = make(map[int]int)

	// Get the number of 2s that divide n
	for n%2 == 0 {
		if _, ok := pfs[2]; ok {
			pfs[2] += 1
		} else {
			pfs[2] = 1
		}
		n = n / 2
	}

	// n must be odd at this point. so we can skip one element
	// (note i = i + 2)
	for i := 3; i*i <= n; i = i + 2 {
		// while i divides n, append i and divide n
		for n%i == 0 {
			if _, ok := pfs[i]; ok {
				pfs[i] += 1
			} else {
				pfs[i] = 1
			}
			n = n / i
		}
	}

	// This condition is to handle the case when n is a prime number
	// greater than 2
	if n > 2 {
		pfs[n] = 1
	}

	return
}

func NumberOfDivisors(n int) int {
	pfs := PrimeFactorization(n)

	num := 1
	for _, exponents := range pfs {
		num *= (exponents + 1)
	}

	return num
}

func KthPrime(x int) (y int) {
	if x == 1 {
		y = 2
	}
	if x == 2 {
		y = 3
	}
	if x > 2 {
		var sum int = 2
		begin := 5
		for sum < x+1 {
			if IsItPrime(begin) == true {
				sum++
			}
			if sum == x {
				y = begin
				break
			} else {
				if begin%6 == 1 {
					begin = begin + 4
				} else {
					begin = begin + 2
				}
			}
		}
	}
	return
}

func MODULE(x, y int) int {
	if x > y {
		return x - y
	} else {
		return y - x
	}
}

func BITAND(x, y int64) int64 {
	var ans int64
	begin := x
	sec := y
	var count int64 = 1
	for 1 == 1 {
		if (begin%2)*(sec%2) == 1 {
			ans = ans + count
			count = count * 2
			begin = int64(begin / 2)
			sec = int64(sec / 2)
			if begin*sec == 0 {
				break
			}

		} else {
			count = count * 2
			begin = int64(begin / 2)
			sec = int64(sec / 2)
			if begin*sec == 0 {
				break
			}
		}
	}
	return ans
}

func Sum(n, m int) int {
	var ans int

	if n == 1 {
		return 0
	} else {
		for i := 2; i < n; i++ {
			ans = (ans + Sum(i, m)) % m
		}
		for j := 2; j < n+1; j++ {
			ans = (ans + Sum(n/j, m)) % m
		}
		return ans
	}
}

func ChangeStringToDate(x string) (t time.Time, err error) {
	t, err = time.Parse("2006-01-02", x)
	return
}

func DiffrenceBetweenTwoDates(first, second time.Time) int64 {
	date := first
	date2 := second
	k := date.Unix() - date2.Unix()
	return k
}

var t int

func main() {
	var input io.Reader = bufio.NewReader(os.Stdin)
	fmt.Fscan(input, &t)

	for o := 0; o < t; o++ {
		var n int
		var c string

		fmt.Fscan(input, &n, &c)

		STRING := make([]byte, 0)
		fmt.Fscan(input, &STRING)

		ARR := make([]int, 0)
		BRR := make([]int, 0)
		for i := 0; i < n; i++ {
			if string(STRING[i]) != c {
				ARR = append(ARR, i+1)
			} else {
				BRR = append(BRR, i+1)
			}
		}

		q := len(ARR)
		sec := len(BRR)

		if q == 0 {
			fmt.Println(0)
		} else {
			qqq := 0
			for i := sec - 1; i > 1; i-- {
				init := 0
				for j := q - 1; j >= 0; j-- {
					if ARR[j] < BRR[i] {
						break
					} else {
						if ARR[j]%BRR[i] == 0 {
							init = 1
							break
						}
					}
				}
				if init == 0 {
					qqq = BRR[i]
					break
				}

			}
			if qqq > 0 {
				fmt.Println(1)
				fmt.Println(qqq)
			} else {
				fmt.Println(2)
				fmt.Println(ARR[q-1])
				if ARR[q-1] > 2 {
					fmt.Println(ARR[q-1] - 1)
				} else {
					fmt.Println(n)
				}

			}

		}
	}

}

package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"time"
)

// var m []int
// err = json.Unmarshal([]byte(r.FormValue("example")), &m)

// for i := 0; i < len(m); i++ {
// 	fmt.Println(m[i])
// }

// sort.Slice(arr, func(i, j int) bool {
// 	return arr[i] > arr[j]
// })

func MIN(x, y int64) int64 {
	if x > y {
		return y
	} else {
		return x
	}
}

func MINN(x, y int) int {
	if x > y {
		return y
	} else {
		return x
	}
}

func MKO(x, y int64) int64 {
	if x < y {
		return 0
	} else {
		return x - y + 1
	}
}

func MAX(x, y int64) int64 {
	if x > y {
		return x
	} else {
		return y
	}
}

func MAXX(x, y int) int {
	if x > y {
		return x
	} else {
		return y
	}
}

func LCM(x, y int) int {
	if x >= y {
		initial := x
		for i := 1; i < y+2; i++ {
			if initial%y == 0 {
				break
			} else {
				initial = initial + x
			}

		}
		return initial
	} else {
		initial := y
		for i := 1; i < x+2; i++ {
			if initial%x == 0 {
				break
			} else {
				initial = initial + y
			}

		}
		return initial
	}
}

func GCD(x, y int64) int64 {
	if x*y == 0 {
		return MAX(x, y)
	} else {
		var l, q int64
		l = MAX(x, y)
		q = MIN(x, y)
		var m int64
		for l*q > 0 {
			a := l % q
			b := l - a
			cc := int64(b / q)
			remain := l - cc*q
			l = MAX(remain, q)
			q = MIN(remain, q)
			if l*q == 0 {
				m = l + q
				break
			}

		}
		return m
	}
}

func IsItPrime(x int) bool {
	if x < 10 {
		if x == 2 || x == 3 || x == 5 || x == 7 {
			return true
		} else {
			return false
		}
	} else {
		j := 0
		k := math.Sqrt(float64(x))
		for m := 3; m <= int(k); {
			if x%m == 0 {
				j = 1
				break
			}
			m = m + 2
		}
		if j == 1 {
			return false
		} else {
			return true
		}
	}
}

func PrimeFactorization(n int) (pfs map[int]int) {
	pfs = make(map[int]int)

	// Get the number of 2s that divide n
	for n%2 == 0 {
		if _, ok := pfs[2]; ok {
			pfs[2] += 1
		} else {
			pfs[2] = 1
		}
		n = n / 2
	}

	// n must be odd at this point. so we can skip one element
	// (note i = i + 2)
	for i := 3; i*i <= n; i = i + 2 {
		// while i divides n, append i and divide n
		for n%i == 0 {
			if _, ok := pfs[i]; ok {
				pfs[i] += 1
			} else {
				pfs[i] = 1
			}
			n = n / i
		}
	}

	// This condition is to handle the case when n is a prime number
	// greater than 2
	if n > 2 {
		pfs[n] = 1
	}

	return
}

func NumberOfDivisors(n int) int {
	pfs := PrimeFactorization(n)

	num := 1
	for _, exponents := range pfs {
		num *= (exponents + 1)
	}

	return num
}

func KthPrime(x int) (y int) {
	if x == 1 {
		y = 2
	}
	if x == 2 {
		y = 3
	}
	if x > 2 {
		var sum int = 2
		begin := 5
		for sum < x+1 {
			if IsItPrime(begin) == true {
				sum++
			}
			if sum == x {
				y = begin
				break
			} else {
				if begin%6 == 1 {
					begin = begin + 4
				} else {
					begin = begin + 2
				}
			}
		}
	}
	return
}

func MODULE(x, y int) int {
	if x > y {
		return x - y
	} else {
		return y - x
	}
}

func BITAND(x, y int64) int64 {
	var ans int64
	begin := x
	sec := y
	var count int64 = 1
	for 1 == 1 {
		if (begin%2)*(sec%2) == 1 {
			ans = ans + count
			count = count * 2
			begin = int64(begin / 2)
			sec = int64(sec / 2)
			if begin*sec == 0 {
				break
			}

		} else {
			count = count * 2
			begin = int64(begin / 2)
			sec = int64(sec / 2)
			if begin*sec == 0 {
				break
			}
		}
	}
	return ans
}

func Sum(n, m int) int {
	var ans int

	if n == 1 {
		return 0
	} else {
		for i := 2; i < n; i++ {
			ans = (ans + Sum(i, m)) % m
		}
		for j := 2; j < n+1; j++ {
			ans = (ans + Sum(n/j, m)) % m
		}
		return ans
	}
}

func ChangeStringToDate(x string) (t time.Time, err error) {
	t, err = time.Parse("2006-01-02", x)
	return
}

func DiffrenceBetweenTwoDates(first, second time.Time) int64 {
	date := first
	date2 := second
	k := date.Unix() - date2.Unix()
	return k
}

var t int

func main() {
	var input io.Reader = bufio.NewReader(os.Stdin)
	fmt.Fscan(input, &t)

	for o := 0; o < t; o++ {
		var n int
		var c string

		fmt.Fscan(input, &n, &c)

		STRING := make([]byte, 0)
		fmt.Fscan(input, &STRING)

		ARR := make([]int, 0)
		for i := 0; i < n; i++ {
			if string(STRING[i]) != c {
				ARR = append(ARR, i+1)
			}
		}

		q := len(ARR)

		fmt.Println(ARR)

		if q == 0 {
			fmt.Println(0)
		} else {
			qqq := 0
			for i := n; i > 1; i-- {
				init := 0
				for j := q - 1; j >= 0; j-- {
					if ARR[j] < i {
						break
					} else {
						if ARR[j]%i == 0 {
							init = 1
							break
						}
					}
				}
				if init == 0 {
					qqq = i
					break
				}

			}
			if qqq > 0 {
				fmt.Println(1)
				fmt.Println(qqq)
			} else {
				fmt.Println(2)
				fmt.Println(ARR[q-1])
				if ARR[q-1] > 2 {
					fmt.Println(ARR[q-1] - 1)
				} else {
					fmt.Println(n)
				}

			}

		}
	}

}

package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()

	var T int
	fmt.Fscan(in, &T)

	for t := 0; t < T; t++ {
		var n int
		var s2 string
		var s string
		fmt.Fscan(in, &n, &s2, &s)

		ch := rune(s2[0])
		z := []int{}
		var a, b int
		for i, v := range s {
			if ch == v {
				var f bool
				for _, n := range z {
					if i%n == 0 {
						f = true
						break
					}
				}

				if !f && i != 0 {
					z = append(z, i+1)
				}
				a++
			} else {
				idx := -1

				for i, n := range z {
					if (i+1)%n == 0 {
						idx = i
						break
					}
				}
				if idx >= 0 {
					z = append(z[:idx], z[idx+1:]...)
				}
				b++
			}
		}

		if a == n {
			fmt.Fprintln(out, 0)
		} else if len(z) > 0 {
			fmt.Fprintln(out, 1)
			fmt.Fprintln(out, z[0])
		} else {
			fmt.Fprintln(out, 2)
			fmt.Fprintf(out, "%d %d\n", n-1, n)
		}
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()

	var T int
	fmt.Fscan(in, &T)

	for t := 0; t < T; t++ {
		var n int
		var b string
		var s string
		fmt.Fscan(in, &n, &b, &s)

		ch := rune(b[0])
		z := []int{}
		for i, v := range s {
			if v != ch {
				if len(z) < 2 {
					z = append(z, i)
				} else {
					break
				}
			}
		}

		if len(z) == 0 {
			fmt.Fprintln(out, 0)
		} else if len(z) == 1 {
			fmt.Fprintf(out, "1\n%d\n", z[0]+2)
		} else if s[n-1] == byte(ch) {
			fmt.Fprintf(out, "1\n%d\n", n)
		} else {
			fmt.Fprintln(out, 2)
			fmt.Fprintf(out, "%d %d\n", n-1, n)
		}
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	r := bufio.NewReaderSize(os.Stdin, 1024*1024)

	var T int
	fmt.Fscanf(r, "%d\n", &T)
	for t := 0; t < T; t++ {
		var n int
		var cs string

		fmt.Fscanf(r, "%d %s\n", &n, &cs)

		var s string
		fmt.Fscanf(r, "%s\n", &s)

		c := cs[0]

		i := 0
		for ; i < n; i++ {
			if s[i] != c {
				break
			}
		}

		if i == n {
			fmt.Println(0)
			continue
		}

		i = 2
		for ; i < n; i++ {
			j := i
			for ; j <= n; j += i {
				if s[j-1] != c {
					break
				}
			}
			if j >= n {
				fmt.Println(1)
				fmt.Println(i)
				break
			}
		}

		if i == n {
			fmt.Println(2)
			fmt.Println(n-1, n)
		}
	}
}