#include <cstdio>
#include <ctime>
#include <iostream>

using namespace std;

#define forn(i, n) for (int i = 0; i < (int)(n); i++)

const int N = 1e5;
const int K = 300;
const int M = N / K + 1;

int a[N];
int z[M];
long long sum[M];

/**
 * [----][----][----][----][----] 
 * z,sum
 */

void relax( int i ) {
  if (z[i] != -1) {
    for (int j = i * K, r = j + K; j < r; j++)
      a[j] = z[i];
    z[i] = -1;
  }
}
void calc( int i ) {
  sum[i] = 0;
  for (int j = i * K, r = j + K; j < r; j++)
    sum[i] += a[j];
}

template <class T> inline void writeInt( T x ) {
  if (x < 0)
    putchar('-'), x = -x;
  char s[24];
  int n = 0;
  while (x || !n)
    s[n++] = '0' + x % 10, x /= 10;
  while (n--)
    putchar(s[n]);
}

int main() {
  int n, q;
  scanf("%d%d", &n, &q);
  memset(z, -1, sizeof(z));
  while (q--) {                              
    int l, r, x;
    char ch;
    scanf(" %c%d%d", &ch, &l, &r), l--, r--;
    if (ch == 'Q') {
      long long res = 0; // O(N/K + K)
      int L = min(r + 1, l % K == 0 ? l : l - l % K + K);
      // for (; l <= r && l % K != 0; l++)
      int Z = z[l / K];
      if (Z == -1)
        for (; l < L; l++)
          res += a[l];
      else
        res += (long long)Z * (L - l), l = L;
      int R = max(l - 1, r % K == K - 1 ? r : r - r % K - 1);
      //for (; l <= r && r % K != K - 1; r--)
      Z = z[r / K];
      for (; R < r; r--)
        res += (Z == -1 ? a[r] : Z);
      for (; l <= r; l += K)
        res += sum[l / K];
      writeInt(res), putchar('\n');
    } else {
      scanf("%d", &x);
      int l0 = l, r0 = r;
      relax(l0 / K);
      relax(r0 / K);
      int L = min(r + 1, l % K == 0 ? l : l - l % K + K);
      // for (; l <= r && l % K != 0; l++)
      for (; l < L; l++)
        a[l] = x;
      int R = max(l - 1, r % K == K - 1 ? r : r - r % K - 1);
      //for (; l <= r && r % K != K - 1; r--)
      for (; R < r; r--)
        a[r] = x;
      calc(l0 / K);
      calc(r0 / K);

      long long T = (long long)K * x;
      for (int i = l / K; l <= r; l += K, i++)
        z[i] = x, sum[i] = T;
    }      
  }
  fprintf(stderr, "time = %.2f\n", 1. * clock() / CLOCKS_PER_SEC); // stamp
}