#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; j < i * K + K; j++)
      a[j] = z[i];
    z[i] = -1;
  }
}
void calc( int i ) {
  sum[i] = 0;
  for (int j = i * K; j < i * K + K; j++)
    sum[i] += a[j];
}

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)
      for (; l <= r && l % K != 0; l++)
        res += (z[l / K] == -1 ? a[l] : z[l / K]);
      for (; l <= r && r % K != K - 1; r--)
        res += (z[r / K] == -1 ? a[r] : z[r / K]);
      for (; l <= r; l += K)
        res += sum[l / K];
      cout << res << endl;
    } else {
      scanf("%d", &x);
      int l0 = l, r0 = r;
      relax(l0 / K);
      relax(r0 / K);
      for (; l <= r && l % K != 0; l++)
        a[l] = x;
      for (; l <= r && r % K != K - 1; r--)
        a[r] = x;
      calc(l0 / K);
      calc(r0 / K);
      for (; l <= r; l += K)
        z[l / K] = x, sum[l / K] = (long long)K * x;
    }      
  }
  fprintf(stderr, "time = %.2f\n", 1. * clock() / CLOCKS_PER_SEC); // stamp
}