#include <bits/stdc++.h>
using namespace std;
const long long mod = 998244353;
const int Max = 1e5 + 1;
int t[4 * Max];
long long pown(long long i, long long n) {
  if (i % n == 0) return (i / n);
  return (i / n) + 1;
}
long long isPrime(long long n) {
  if (n <= 1) return 1;
  if (n <= 3) {
    if (n == 2)
      return 2;
    else
      return 3;
  }
  if (n % 2 == 0 || n % 3 == 0) {
    if (n % 2 == 0)
      return 2;
    else
      return 3;
  }
  for (long long i = 5; i * i <= n; i = i + 6)
    if (n % i == 0 || n % (i + 2) == 0) {
      if (n % i == 0)
        return i;
      else
        return i + 2;
    }
  return n;
}
long long isPower(long long n) {
  if (n <= 1) return false;
  if (n <= 3) {
    return n;
  }
  if (n % 2 == 0 || n % 3 == 0) {
    if (ceil(log2(n)) == floor(log2(n))) {
      return 2;
    } else if (ceil(log2(n) / log2(3)) == floor(log2(n) / log2(3))) {
      return 3;
    } else {
      return 0;
    }
  }
  for (long long i = 5; i * i <= n; i = i + 6)
    if (n % i == 0 || n % (i + 2) == 0) {
      if (n % i == 0 && ceil(log(n) / log(i)) == floor(log(n) / log(i))) {
        return i;
      }
      if (n % (i + 2) == 0 &&
          ceil(log(n) / log(i + 2)) == floor(log(n) / log(i + 2))) {
        return i + 2;
      }
    }
  return n;
}
long long greatest_power(long long p, long long n) {
  long long u = ceil(log(n) / log(p));
  long long sum = 0;
  long long f = p;
  for (int i = 1; i <= u + 1; i++) {
    sum += (n / f);
    f = f * p;
  }
  return sum;
}
long long gcd(long long a, long long b) {
  if (a == 0) {
    return b;
  } else if (b == 0) {
    return a;
  } else if (a > b) {
    return gcd(b, a % b);
  } else {
    return gcd(a, b % a);
  }
}
long long modinv(long long a, long long b) {
  long long res = 1;
  while (b > 0) {
    if (b & 1) {
      res = ((res % mod) * (a % mod)) % mod;
      res = res % mod;
    }
    a = ((a % mod) * (a % mod)) % mod;
    b >>= 1;
  }
  return res;
}
void build(int v, int tl, int tr, string s) {
  if (tl == tr) {
    int u = (int)(s[tl - 1] - 96);
    u--;
    t[v] = t[v] | (1 << u);
  } else {
    int tm = (tl + tr) / 2;
    build(2 * v, tl, tm, s);
    build(2 * v + 1, tm + 1, tr, s);
    t[v] = t[2 * v] | t[2 * v + 1];
  }
}
void update(int v, int tl, int tr, char s[], int pos, char c) {
  if (tl == tr) {
    long long u = (int)(s[tl - 1] - 96);
    u--;
    long long w = (int)(c - 96);
    w--;
    t[v] = t[v] & (~(1 << u));
    t[v] = t[v] | (1 << w);
    s[tl - 1] = c;
  } else {
    int tm = (tl + tr) / 2;
    if (pos <= tm) {
      update(2 * v, tl, tm, s, pos, c);
    } else {
      update(2 * v + 1, tm + 1, tr, s, pos, c);
    }
    t[v] = t[2 * v] | t[2 * v + 1];
  }
}
long long sum(int v, int tl, int tr, int l, int r) {
  if (l > r) {
    return 0;
  } else if (tl == l & tr == r) {
    return t[v];
  } else {
    int tm = (tl + tr) / 2;
    return sum(2 * v, tl, tm, l, min(r, tm)) |
           sum(2 * v + 1, tm + 1, tr, max(l, tm + 1), r);
  }
}
void solve() {
  string s;
  cin >> s;
  long long q;
  cin >> q;
  long long n = s.length();
  int u, v;
  char w;
  int w1;
  build(1, 1, n, s);
  char ch[n];
  for (int i = 0; i < n; i++) {
    ch[i] = s[i];
  }
  while (q--) {
    cin >> u;
    if (u == 1) {
      cin >> v >> w;
      update(1, 1, n, ch, v, w);
    } else {
      cin >> v >> w1;
      long long s = sum(1, 1, n, v, w1);
      long long count = 0;
      while (s > 0) {
        if (s % 2 == 1) {
          count++;
        }
        s = s / 2;
      }
      cout << count << "\n";
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  solve();
}
