#include <algorithm>
#include <numeric>
#include <string>
#include <string.h>
#include <map>
#include <set>
#include <vector>
#include <queue>
#include <iostream>
#include <fstream>
#include <cmath>
#include <math.h>
#include <iomanip>
#include <stdlib.h>
using namespace std;
#define FOR(i,n) for (int i=0; i<n; ++i)
#define FORE(i,n) for (int i=0; i<=n; ++i)
#define REP(i,a,b) for (int i=a; i<b; ++i)
#define REPE(i,a,b) for (int i=a; i<=b; ++i)
#define ALL(c) (c).begin(), (c).end()
#define DEC(i,n) for(int i=n-1;i>=0;i--)
#define SORT(c) sort(ALL(c))

typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long int LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<bool> VB;
const double pi = acos(-1.0);
const int INF =(int) 1e9;
const LL prime = 31;

//////////////////////////////////////////////////////////////////////////////
                            #define PeaceOnYou 1
//////////////////////////////////////////////////////////////////////////////
int mirror(int x)
{
    int result = 0;
    while(x>0)
    {
        result*=10;
        result+=x%10;
        x/=10;
    }
    return result;
}
int main() {

#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
#endif
    int ots=0;
    string s;
    char tg[4];
    cin>>s;int i=0;
    while(i<s.length())
    {
        tg[0]=s[i];i++;
        tg[1]=s[i];i++;
        if(tg[1]=='/')
           {ots--;
           tg[2]=s[i];i++;
           tg[3]=s[i];i++;
           for(int j=0;j<2*ots;j++)cout<<" ";  cout<<tg[0]<<tg[1]<<tg[2]<<tg[3]<<endl;
           }
        else
           {tg[2]=s[i];i++;
           for(int j=0;j<2*ots;j++)cout<<" ";  cout<<tg[0]<<tg[1]<<tg[2]<<endl;
           ots++;
           }
    }
    return 0;
}


#include <algorithm>
#include <numeric>
#include <string>
#include <string.h>
#include <map>
#include <set>
#include <vector>
#include <queue>
#include <iostream>
#include <fstream>
#include <cmath>
#include <math.h>
#include <iomanip>
#include <stdlib.h>
using namespace std;
#define FOR(i,n) for (int i=0; i<n; ++i)
#define FORE(i,n) for (int i=0; i<=n; ++i)
#define REP(i,a,b) for (int i=a; i<b; ++i)
#define REPE(i,a,b) for (int i=a; i<=b; ++i)
#define ALL(c) (c).begin(), (c).end()
#define DEC(i,n) for(int i=n-1;i>=0;i--)
#define SORT(c) sort(ALL(c))

typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long int LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<bool> VB;
const double pi = acos(-1.0);
const int INF =(int) 1e9;
const LL prime = 31;

//////////////////////////////////////////////////////////////////////////////
                            #define PeaceOnYou 1
//////////////////////////////////////////////////////////////////////////////
int mirror(int x)
{
    int result = 0;
    while(x>0)
    {
        result*=10;
        result+=x%10;
        x/=10;
    }
    return result;
}
int main() {

#ifdef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
#endif
    int ots=0;
    string s;
    char tg[4];
    cin>>s;int i=0;
    while(i<s.length())
    {
        tg[0]=s[i];i++;
        tg[1]=s[i];i++;
        if(tg[1]=='/')
           {ots--;
           tg[2]=s[i];i++;
           tg[3]=s[i];i++;
           for(int j=0;j<2*ots;j++)cout<<" ";  cout<<tg[0]<<tg[1]<<tg[2]<<tg[3]<<endl;
           }
        else
           {tg[2]=s[i];i++;
           for(int j=0;j<2*ots;j++)cout<<" ";  cout<<tg[0]<<tg[1]<<tg[2]<<endl;
           ots++;
           }
    }
    return 0;
}


#include <iostream>
#include <string>
using namespace std;

int main()
{ int n=0;int f=0;int c=0;;
int m[100]={0};
char w[100];
string s;
cin>>s;
for (int i=0; i<s.length(); i++)
{
    switch (s[i]){
        case '<':{
            if(s[i+1]=='/')c--;

            for (int j=0;j<c*2;j++)cout<<" ";
                    cout<<"<";
                    c++;break;}
        case '>':{cout<<">"<<endl;break;}
        case '/':{cout<<"/";c--;break;}
        default: {cout<<s[i];}

    }

}

   return 0;
}


#include <iostream>
#include <cstring>
#include <string>

using namespace std;

int main()
 {
//	 freopen("input.txt","r",stdin);
//	 freopen("output.txt","w",stdout);
	 string s;
	 getline(cin,s);
	 int n=s.length();
	 int t=0,i=0;
	 while (i<n)
	  if (s[i+1]!='/')
	  {
			for (int j=1;j<=t;j++) cout<<" ";
			cout<<"<"<<s[i+1]<<">\n";
  	  t+=2;
			i+=3;

		}	 else
		 {
			t-=2;
			for (int j=1;j<=t;j++) cout<<" ";
			cout<<"</"<<s[i+2]<<">\n";
			i+=4;
  		}
	 return 0;
 }


#include <iostream>
#include <cstring>
#include <string.h>

using namespace std;

int main()
 {
//	 freopen("input.txt","r",stdin);
//	 freopen("output.txt","w",stdout);
	 string s;
	 getline(cin,s);
	 int n=s.length();
	 int t=0,i=0;
	 while (i<n)
	  if (s[i+1]!='/')
	  {
			for (int j=1;j<=t;j++) cout<<" ";
			cout<<"<"<<s[i+1]<<">\n";
  	  t+=2;
			i+=3;

		}	 else
		 {
			t-=2;
			for (int j=1;j<=t;j++) cout<<" ";
			cout<<"</"<<s[i+2]<<">\n";
			i+=4;
  		}
	 return 0;
 }


#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdlib.h>
//#include <template>
//#include <stdlib>

using namespace std;

#define REP(i,n) for (int i=0, _n=(n)-1; i <= _n; i++)
#define REPD(i,n) for (int i=(n)-1; i >= 0; i--)
#define FOR(i,a,b) for (int i=(a), _b=(b); i <=_b; i++)
#define FORD(i,a,b) for (int i=(a), _b=(b); i >=_b; i--)
#define X first
#define Y second

template < class T, class Container = deque<T> > class stack;
template < class T > T sqr (T a) { return (a) * (a); }
template < class T > T abs (T a) { return (a < 0) ? -(a) : a; }

void Show(vector <char> q, vector <int> deep, int m) {
	REP(j,2*deep[m])
		printf(" ");
	printf("<%c>\n",q[m]);
	if (m<q.size()-1) Show(q,deep,m+1);
	REP(j,2*deep[m])
		printf(" ");
	printf("</%c>\n",q[m]);
}

int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif

	char ch;
	string s;
	vector <char> q;
	vector <int> deep(1);
	int count=0;
	bool slash;

	while (scanf("%c",&ch)==1 && ch!='\n')
		if (ch=='<') {
			scanf("%c",&ch);

			if (ch=='/') {
				scanf("%c",&ch);
//				slash=1;
				REP(i,2*count-2)
					printf(" ");
				printf("</%c>\n",ch);
				count--;
			}
			else {
//				slash=0;
				REP(i,2*count)
					printf(" ");
				printf("<%c>\n",ch);
				count++;
			}

/*			REP(i,2*count-2)
				printf(" ");
			if (slash) {
				printf("  </%c>\n",ch);

			}
			else {
				printf("<%c>\n",ch);
				//
			}*/

			scanf("%c",&ch);

		}

	return 0;
}


#include <iostream>
#include <string>
#include <stack>
using namespace std;

struct xmltag {
	char name;
	bool open;
	int level;
};

int main()
{
	int i, j, p, level;
	bool in;
	xmltag tag;
	xmltag arr[1000];
	stack <xmltag> st;
	string line;

	getline(cin, line);
	i = p = level = 0;
	while (i < line.length()) {
		if (line[i] == '<') {
			if (line[i+1] == '/') {
				tag.open = false;
				tag.name = line[i+2];
				i += 4;
				if (st.top().name == tag.name && st.top().open == true) {
					tag.level = --level;
					st.pop();
				}
				arr[p++] = tag;
			} else {
				tag.open = true;
				tag.name = line[i+1];
				tag.level = level++;
				i += 3;
				st.push(tag);
				arr[p++] = tag;
			}
		}
	}
	for (i = 0;i<p;i++) {
		if (arr[i].level != 0) {
			for (j = 0; j <= arr[i].level; j++) {
				cout << " ";
			}
		}
		if (arr[i].open) {
			cout << "<" << arr[i].name << ">" << endl;
		} else {
			cout << "<" << "/" << arr[i].name << ">" << endl;
		}
	}
	return 0;
}


#include <iostream>
#include <string>
#include <stack>
using namespace std;

struct xmltag {
	char name;
	bool open;
	int level;
};

int main()
{
	int i, j, p, level;
	bool in;
	xmltag tag;
	xmltag arr[1000];
	stack <xmltag> st;
	string line;

	getline(cin, line);
	i = p = level = 0;
	while (i < line.length()) {
		if (line[i] == '<') {
			if (line[i+1] == '/') {
				tag.open = false;
				tag.name = line[i+2];
				i += 4;
				if (st.top().name == tag.name && st.top().open == true) {
					tag.level = --level;
					st.pop();
				}
				arr[p++] = tag;
			} else {
				tag.open = true;
				tag.name = line[i+1];
				tag.level = level++;
				i += 3;
				st.push(tag);
				arr[p++] = tag;
			}
		}
	}
	for (i = 0;i<p;i++) {
		if (arr[i].level != 0) {
			for (j = 1; j <= 2*arr[i].level; j++) {
				cout << " ";
			}
		}
		if (arr[i].open) {
			cout << "<" << arr[i].name << ">" << endl;
		} else {
			cout << "<" << "/" << arr[i].name << ">" << endl;
		}
	}
	return 0;
}


#include <iostream>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <string>

using namespace std;

int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	string s;
	cin >> s;
	int p = 1, d = 0;
	while(p < (int)s.length())
	{
		if(s[p] == '/')
		{
			for(int i = d; i--; )
				cout << ' ' << ' ';
			cout << s.substr(p - 1, 4) << '\n';
			d--, p++;
		}
		else
		{
			d++;
			for(int i = d; i--; )
				cout << ' ' << ' ';
			cout << s.substr(p - 1, 3) << '\n';
		}
		p += 3;
	}
}


#include <iostream>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <string>

using namespace std;

int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	string s;
	cin >> s;
	int p = 1, d = 0;
	while(p < (int)s.length())
	{
		if(s[p] == '/')
		{
			for(int i = d; i--; )
				cout << ' ' << ' ';
			cout << s.substr(p - 1, 4);
			if(p + 4 < (int)s.length())
				cout << '\n';
			d--, p++;
		}
		else
		{
			d++;
			for(int i = d; i--; )
				cout << ' ' << ' ';
			cout << s.substr(p - 1, 3) << '\n';
		}
		p += 3;
	}
}


#include <iostream>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <string>

using namespace std;

int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	string s;
	cin >> s;
	int p = 1, d = 0;
	while(p < (int)s.length())
	{
		if(s[p] == '/')
		{
			d--, p++;
			for(int i = d; i--; )
				cout << ' ' << ' ';
			cout << s.substr(p - 2, 4);
			if(p + 4 < (int)s.length())
				cout << '\n';
		}
		else
		{
			for(int i = d; i--; )
				cout << ' ' << ' ';
			cout << s.substr(p - 1, 3) << '\n';
			d++;
		}
		p += 3;
	}
}


#include <iostream>
#include <vector>
// #include <set>
// #include <stack>
// #include <queue>
// #include <string>
// #include <math.h>
// #include <iterator>

using namespace std;

int main()
{
/*
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
*/
	int n;
	cin >> n;

	int d = 0;
	while(true)
	{
		int dd = 1;
		while(n * 2 >= (dd | d) * ((dd | d) - 1) && !(d & dd))
			dd <<= 1;
		dd >>= 1;
		if(d & dd || !dd)
			break;
		else
			d |= dd;
	}

	vector<vector<int>> r(d, vector<int>());
	int h = 0;
	for(int i = 0; i < d; i++)
		for(int j = i + 1; j < d; j++)
			h++, r[i].push_back(h), r[j].push_back(h);

	cout << d << '\n';
	for(int i = 0; i < d; i++)
	{
		// copy(r[i].begin(), r[i].end(), ostream_iterator<int>(cout, " ")), cout << endl;
		for(int j = 0; j < (int)r[i].size(); j++)
			cout << r[i][j] << ' ';
		cout << '\n';
	}

	return 0;
}


#include <ctime>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>

#include <algorithm>
#include <iostream>
#include <iomanip>
#include <bitset>
#include <vector>
#include <queue>
#include <map>
#include <set>

using namespace std;

string data;
vector< pair<char, int> > tags;

void print(int l, int r, int deep)
{
	if (l > r) return;
	cout << string(2 * deep, ' ') << "<" << tags[l].first << ">" << endl;
	int balance = 0;
	for (int i = l; i <= r; i++)
	{
		if (tags[i].first != tags[l].first) continue;
		balance += tags[i].second;
		if (balance != 0) continue;
		print(l + 1, i - 1, deep + 1);
		cout << string(2 * deep, ' ') << "</" << tags[l].first << ">" << endl;
		print(i + 1, r, deep);
		return;
	}
}

int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	cin >> data;
	for (int i = 0; i < data.length();)
	{
		if (data[i + 1] == '/') tags.push_back(make_pair(data[i + 2], -1)), i += 4;
		else tags.push_back(make_pair(data[i + 1], 1)), i += 3;
	}
	print(0, tags.size() - 1, 0);
	return 0;
}


#include <iostream>
using namespace std;

int main(){

    int h = 0,i,flag=0;
    char buf,size[4];
    while (true){
        i=0;
        while (true){
            buf= getchar();
            if (buf=='\n') return 0;
            size[i] = buf;
            i++;
            if (buf=='/'){ flag = 0; h-=2; }
            if (buf=='>') { if (flag) cout << ' ' << ' ';h++; break; }
        }
        for (int j=0;j<i;j++) cout << size[j];
        cout << endl;
        for (int j=0;j<2*(h-1);j++) cout << ' ';
        flag = 1;
    }
return 0;
}


#include <iostream>
using namespace std;

int main(){

    int h = 0,i,flag,amount=0;
    char buf,size[4];
    while (true){
        i=0; flag = 1;
        while (true){
            buf= getchar();
            if (buf=='\n') return 0;
            size[i] = buf;
            i++;
            if (buf=='/') { h-=2; flag=0; }
            if (buf=='>') {
                if (!h) amount = 0;
                h++;
                if (flag&&amount) cout << ' ' << ' ';
                break;
            }
        }
        amount++;
        for (int j=0;j<i;j++) cout << size[j];
        cout << endl;
        for (int j=0;j<2*(h-1);j++) cout << ' ';
    }
return 0;
}


#include <iostream>
using namespace std;

int main(){

    int h = 0,i;
    char buf,size[4];
    while (true){
        i=0;
        while (true){
            buf= getchar();
            if (buf=='\n') return 0;
            size[i] = buf;
            i++;
            if (buf=='/'){
                h-=2;
                printf("\b\b");
            }
            if (buf=='>') { h++; break; }
        }
        for (int j=0;j<i;j++) cout << size[j];
        cout << endl;
        for (int j=0;j<2*h;j++) cout << ' ';
    }
return 0;
}


#include <iostream>
using namespace std;

int main(){

    int h = 0,i,flag,amount=0;
    char buf,size[4];
    while (true){
        i=0; flag = 1;
        while (true){
            buf= getchar();
            if (buf=='\n') break;
            size[i] = buf;
            i++;
            if (buf=='/') { h-=2; flag=0; }
            if (buf=='>') {
                if (!h) amount = 0;
                h++;
                if (flag&&amount) cout << ' ' << ' ';
                break;
            }
        }
        amount++;
        for (int j=0;j<i;j++) cout << size[j];
        cout << endl;
        for (int j=0;j<2*(h-1);j++) cout << ' ';
    }
return 0;
}


#include <iostream>
using namespace std;

int main(){

    int h = 0,i,flag,amount=0;
    char buf,size[4];
    while (true){
        i=0; flag = 1;
        while (true){
            buf= getchar();
            if (buf=='\n') return 0;
            size[i] = buf;
            i++;
            if (buf=='/') { h-=2; flag=0; }
            if (buf=='>') {
                h++;
                    if (flag&&amount) cout << ' ' << ' ';
                break;
            }
        }
        amount++;
        for (int j=0;j<i;j++) cout << size[j];
        cout << endl;
        for (int j=0;j<2*(h-1);j++) cout << ' ';
    }
return 0;
}


#include <iostream>
using namespace std;

int main(){

    int h = 0,i,flag,amount=0;
    char buf,size[4];
    while (true){
        i=0; flag = 1;
        while (true){
            buf= getchar();
            if (buf=='\n') return 0;
            size[i] = buf;
            i++;
            if (buf=='/') { h-=2; flag=0; if (!h) amount = 0; }
            if (buf=='>') {
                h++;
                    if (flag&&amount) cout << ' ' << ' ';
                break;
            }
        }
        amount++;
        for (int j=0;j<i;j++) cout << size[j];
        cout << endl;
        for (int j=0;j<2*(h-1);j++) cout << ' ';
    }
return 0;
}


#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <set>
#include <algorithm>
#include <cmath>
using namespace std;
string s;
int main()
{
    cin>>s;
    string empty = "";
    for(int i=0;i<s.length();)
    {
        ++i;
        if(s[i]=='/')
        {
            empty.resize(empty.size()-2);
            cout<<empty;
            ++i;
            cout<<"</"<<s[i]<<'>';
            i+=2;
        }
        else
        {
            cout<<empty;
            cout<<"<"<<s[i]<<">";
            i+=2;
            empty+="  ";
        }
        cout<<endl;
    }
/*  int n;
    cin>>n;
    int l = n-(n/36)*36;
    cout<<n/36<<" "<<l/3+(l%3>=2);*/
    return 0;
}


#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <sstream>

#define pb push_back
#define mp make_pair
#define PI 3.14159265358979
#define sqr(x) (x)*(x)
#define forn(i, n) for(int i = 0; i < n; ++i)
#define ALL(x) x.begin(), x.end()
#define sz(x) int((x).size())
#define X first
#define Y second
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<int,int> pii;
const int INF = 2147483647;
const ll LLINF = 9223372036854775807LL;
int used[300] = {};
int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	string s; cin >> s;
	int bal = 0;
	for (int i = 0; i < s.length(); ++i) {
		int cur = s[i];
		if (cur >= 'a' && cur <= 'z') {
			if (!used[cur]) {
				for (int i = 0; i < bal * 2; ++i) putchar(' ');
				printf("<%c>\n", cur);
				bal++;
				used[cur] = 1;
			} else {
				bal--;
				for (int i = 0; i < bal * 2; ++i) putchar(' ');
				used[cur] = 0;
				printf("</%c>\n", cur);

			}
		}
	}
	return 0;
}


#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <sstream>

#define pb push_back
#define mp make_pair
#define PI 3.14159265358979
#define sqr(x) (x)*(x)
#define forn(i, n) for(int i = 0; i < n; ++i)
#define ALL(x) x.begin(), x.end()
#define sz(x) int((x).size())
#define X first
#define Y second
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<int,int> pii;
const int INF = 2147483647;
const ll LLINF = 9223372036854775807LL;
int used[300] = {};
int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	string s; cin >> s;
	int bal = 0;
	for (int i = 0; i < s.length(); ++i) {
		int cur = s[i];
		if (cur >= 'a' && cur <= 'z') {
			if (s[i - 1] != '/') {
				for (int i = 0; i < bal * 2; ++i) putchar(' ');
				printf("<%c>\n", cur);
				bal++;
				used[cur] = 1;
			} else {
				bal--;
				for (int i = 0; i < bal * 2; ++i) putchar(' ');
				used[cur] = 0;
				printf("</%c>\n", cur);

			}
		}
	}
	return 0;
}


#include<stdio.h>
#include<stdlib.h>

int main(){
    int lv=0;
    while(true){
        char tmp[1000];
        int k=0;
        while(true){
            if(scanf("%c",&tmp[k++])==EOF)return 0;
            if(tmp[k-1]=='\n')return 0;
            if(tmp[k-1]=='>'){
                tmp[k]='\0';
                break;
            }
        }
        if(tmp[1]!='/'){
            for(int i=0;i<2*lv;i++)printf(" ");
            printf("%s\n",tmp);
            lv++;
        }
        else{

            lv--;

            for(int i=0;i<2*lv;i++)printf(" ");
            printf("%s\n",tmp);        }
    }
}


#include<iostream>
#include<cstring>
using namespace std;
char s[1005];
int main()
{
    while(scanf("%s",s)!=EOF)
    {
        int i=1;
        int len=strlen(s);
        int h=0;
        while(i<len)
        {
            if(s[i]!='/')
            {
                for(int j=0;j<2*h;j++)printf(" ");
                printf("<%c>\n",s[i]);
                h++;
                i+=3;
            }
            else
            {
                h--;
                for(int j=0;j<2*h;j++)
                printf(" ");
                printf("</%c>\n",s[i+1]);
                i+=4;
            }
        }
    }
    return 0;
}


#include <iostream>
#include <algorithm>
#include <string>
using namespace std;

int main(){
	string s;
	cin >> s;
	int h=0;
	for (int i=0; i<s.length(); ++i){
		if (s[i] == '<'){
			if (s[i+1] == '/') --h;
			for (int j=0; j<2*h; j++) cout << ' ';
			++h;
		}
		if (s[i] == '/') --h;
		cout << s[i];
		if (s[i] == '>') cout << endl;
	}

	return 0;
}


#include <algorithm>
#include <iostream>
#include <fstream>
#include <cstring>
#include <string>
#include <cstdio>
#include <vector>
#include <cmath>
#include <queue>
#include <stack>
#include <queue>
#include <set>
#include <map>
#define clr(a,b) memset(a,b,sizeof(a))
#define cpy(a,b) memcpy(a,b,sizeof(b))
using namespace std;
//<c></c>
stack<char> stk;
void space(int n){
	for(int i=0;i<n;i++)
		cout<<" ";
}
int main(){
	//freopen("in.txt","r",stdin);
	string str;
	getline(cin,str);
	int h=0;
	for( int i=0 ; i<str.size() ; i ++ ){
		bool sw=true;
		if(str[i]=='<')
			i++;
		if(str[i]=='/'){
			sw=false;
			i++;
		}
		if( str[i] <= 'z' && str[i] >= 'a' && sw==true){
			stk.push(str[i]);
			space(h*2);
			cout<<"<"<<str[i]<<">"<<endl;
			h++;
		}
		else if(str[i] <= 'z' && str[i] >= 'a' && sw==false){
			stack<char> temp;
			while( stk.top() != str[i] ){
				temp.push(stk.top());
				stk.pop();
			}
			stk.pop();
			while(temp.size()>0){
				space(h*2);
				cout<<"<"<<temp.top()<<">"<<endl;
				temp.pop();
			}
			h--;
			space(h*2);
			cout<<"</"<<str[i]<<">"<<endl;
		}
		i++;
	}
}


#include <iostream>
#include <stdlib.h>
#include <vector>
#include <string>
using namespace std;

char str[1010];

int main()//16
{
	//<c></c>
	scanf("%s",str);
	string ss="";
	int flag=0;
	int ji=0;

	for(int i=0;str[i];i++)
	{
		if(str[i]=='<')
		{
			flag=1;
		}
		else if(str[i]=='/')
		{
			flag=-1;
			ss+=str[i];
		}
		else if(str[i]=='>')
		{
			if(flag==1)
				ji++;
			for(int j=0;j<ji-1;j++)
			{
				printf("  ");
			}
			if(flag==-1)
				ji--;
			cout<<"<"<<ss<<">"<<endl;
			flag=0;
			ss="";
			continue;
		}
		else
			ss+=str[i];
	}

	return 0;
}


//this problem is solved by pol

#include <iostream>
#include <string>

using namespace std;

int main()
{int ots=0;
string s;
char tg[4];
cin>>s;int i=0;
while(i<s.length())
{
tg[0]=s[i];i++;
tg[1]=s[i];i++;
if(tg[1]=='/')
   {ots--;
   tg[2]=s[i];i++;
   tg[3]=s[i];i++;
   for(int j=0;j<2*ots;j++)cout<<" ";  cout<<tg[0]<<tg[1]<<tg[2]<<tg[3]<<endl;
   }
else
   {tg[2]=s[i];i++;
   for(int j=0;j<2*ots;j++)cout<<" ";  cout<<tg[0]<<tg[1]<<tg[2]<<endl;
   ots++;
   }
}
return 0;}


//this problem is solved by pol

#include <iostream>
#include <string>

using namespace std;

int main()
{int ots=0;
string s;
char tg[4];
bool op=true;
cin>>s;int i=0;
while(i<s.length())
{
tg[0]=s[i];i++;
tg[1]=s[i];i++;
if(tg[1]=='/')
   {op=false;
   tg[2]=s[i];i++;
   tg[3]=s[i];i++;
   for(int j=0;j<2*ots;j++)cout<<" ";  cout<<tg[0]<<tg[1]<<tg[2]<<tg[3]<<endl;
   ots--;
   }
else
   {op=true;
   tg[2]=s[i];i++;
   for(int j=0;j<2*ots;j++)cout<<" ";  cout<<tg[0]<<tg[1]<<tg[2]<<endl;
   ots++;
   }
}
return 0;}


//this problem is solved by pol

#include <iostream>
#include <string>

using namespace std;

int main()
{int ots=0;
string s;
char tg[4];
bool op=true;
cin>>s;i=0;
while(i<s.length())
{
tg[0]=s[i];i++;
tg[1]=s[i];i++;
if(tg[1]=='/')
   {op=false;
   tg[2]=s[i];i++;
   tg[3]=s[i];i++;
   for(int j=0;j<2*ots;j++)cout<<" ";  cout<<tg[0]<<tg[1]<<tg[2]<<tg[3]<<endl;
   ots--;
   }
else
   {op=true;
   tg[2]=s[i];i++;
   for(int j=0;j<2*ots;j++)cout<<" ";  cout<<tg[0]<<tg[1]<<tg[2]<<endl;
   ots++;
   }
}
return 0;}


#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <vector>
#include <algorithm>

using namespace std;

typedef struct _node{
    char letter;
    int status, h;
}node;

char S[1005];
int L;

vector<node> List;

node makeNode(char l, int s, int h){
    node newNode;
    newNode.letter = l, newNode.status = s, newNode.h = h;
    return newNode;
}

int main(void){
    int i, j, Last = 3;
    char letter;
    int status, h;
    //freopen("input.txt", "r", stdin);
    scanf("%s", S+1);
    L = strlen(S+1);
    List.push_back(makeNode(S[2], 1, 0));
    for(i=4; i<=L; i++){
        if(S[i] != '>') continue;
        letter = S[i-1];
        if(i - Last == 3){
            status = 1;
            if(List[List.size()-1].status == 1) h = List[List.size()-1].h+2;
            else h = List[List.size()-1].h;
        } else if(i - Last == 4){
            status = -1;
            if(List[List.size()-1].status == 1) h = List[List.size()-1].h;
            else h = List[List.size()-1].h-2;
        }
        Last = i;
        List.push_back(makeNode(S[i-1], status, h));
    }

    for(i=0; i<List.size(); i++){
        for(j=0; j<List[i].h; j++) printf(" ");
        if(List[i].status == 1){
            printf("<%c>\n", List[i].letter);
        } else{
            printf("</%c>\n", List[i].letter);
        }
    }

    return 0;
}


#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<vector>
#define mm(a,b) memset(a,b,sizeof(a))
using namespace std;
void print(int n)
{
	for(int i=0;i<n;i++)
		printf("  ");
}
int main()
{
	char c[1010];
	gets(c);
	int n=strlen(c);
	int k=0;
	for(int i=1;i<n;i+=3)
	{
		if(c[i]!='/')
		{
			print(k);
			k++;
			printf("<%c>\n",c[i]);
		}
		else
		{
			k--;
			print(k);
			printf("</%c>\n",c[i+1]);
			i++;
		}
	}
	return 0;
}


#pragma comment (linker, "/STACK:1000000000")

#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

void print(int n) {
	for (int i = 0; i < n; i++) {
		printf(" ");
	}
}

int main() {
	freopen("input.txt", "r", stdin);
	char c;
	string s;
	vector <string> st;
	while (scanf("%c", &c) != EOF) {
		s += c;
		if (c == '>') {
			bool type = ('a' <= s[1] && s[1] <= 'z');
			if (type) {
				print(2 * st.size());
				printf("%s\n", s.c_str());
				st.push_back(s);
			} else {
				st.pop_back();
				print(2 * st.size());
				printf("%s\n", s.c_str());
			}
 			s = "";
		}
	}
	return 0;
}


#pragma comment (linker, "/STACK:1000000000")

#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

void print(int n) {
	for (int i = 0; i < n; i++) {
		printf(" ");
	}
}

int main() {
	//freopen("input.txt", "r", stdin);
	char c;
	string s;
	vector <string> st;
	while (scanf("%c", &c) != EOF) {
		s += c;
		if (c == '>') {
			bool type = ('a' <= s[1] && s[1] <= 'z');
			if (type) {
				print(2 * st.size());
				printf("%s\n", s.c_str());
				st.push_back(s);
			} else {
				st.pop_back();
				print(2 * st.size());
				printf("%s\n", s.c_str());
			}
 			s = "";
		}
	}
	return 0;
}


#include <iostream>
#include <string>
#include <algorithm>
#include <stack>

int main()
{
    std::string s, s0;
    std::getline ( std::cin, s );
    s.erase ( std::remove ( s.begin(), s.end(), ' ' ), s.end() );
    std::stack < std::pair < std::string, int > > st;
    int level = 0, i = 0, k = 0;
    bool flag = false;
    while ( !s.empty() )
    {
        s0 = s.substr ( 0, s.find ( '>' ) + 1 );
        if ( s0.find ( '/' ) < s0.size() )
        {
            k = st.top().second / 2;
            s0.insert ( s0.begin(), st.top().second, ' ' );
            std::cout << s0 << std::endl;
            st.pop();
            i = 0; flag = true;
        }
        else
        {
            if ( st.empty() ) level = 0;
            if ( flag && !st.empty() ) level = k;
            flag = false;
            st.push ( std::pair < std::string, int > ( s0, level * 2 ) );
            s0.insert ( s0.begin(), level * 2, ' ' );
            std::cout << s0 << std::endl;
            level++;
        }
        s.erase ( 0, s.find ( '>' ) + 1 );
    }
}


#include<stdio.h>
#include<string.h>
bool tagStart(int);
char indentedStr[4000];
char str[1000];
int main(){
  gets(str);
  int i =0;
  int tagLevel = 0;
  int textIndex = 0;
  for(;str[i]!=0;){
      if(str[i]=='<'){
          if(tagStart(i)){

              for(int j = 0; j< tagLevel*2; j++){
                  printf(" ");
              }
              printf("%c%c%c%c",str[i],str[i+1],str[i+2],'\n');
              tagLevel++;
              i+=3;
          }
          else{
              tagLevel--;
              for(int j = 0; j< tagLevel*2; j++){
                  printf(" ");
              }
              printf("%c%c%c%c%c",str[i],str[i+1],str[i+2],str[i+3],'\n');
              i+=4;
          }
      }

  }
  return 0;
}

bool tagStart(int index){
    return str[index+1] != '/';
}


#include<stdio.h>
#include<string.h>
bool tagStart(int);
char indentedStr[4000];
char str[1000];
int main(){
  gets(str);
  int i =0;
  int tagLevel = 0;
  int textIndex = 0;
  for(;str[i]!=0;){
      if(str[i]=='<'){
          if(tagStart(i)){

              for(int j = 0; j< tagLevel*2; j++){
                  printf(" ");
              }
              printf("%c%c%c%c%c",str[i],str[i+1],str[i+2],'\n');
              tagLevel++;
              i+=3;
          }
          else{
              tagLevel--;
              for(int j = 0; j< tagLevel*2; j++){
                  printf(" ");
              }
              printf("%c%c%c%c%c",str[i],str[i+1],str[i+2],str[i+3],'\n');
              i+=4;
          }
      }

  }
  return 0;
}

bool tagStart(int index){
    return str[index+1] != '/';
}


#include<stdio.h>
#include<string.h>
bool tagStart(int);
bool tagEnd(int);
char indentedStr[4000];
char str[1000];
int main(){
  gets(str);
  int i =0;
  int tagLevel = 0;
  int textIndex = 0;
  for(;str[i]!=0;){
      if(str[i]=='<'){
          if(tagStart(i)){

              for(int j = 0; j< tagLevel*2; j++){
                  printf(" ");
              }
              printf("%c%c%c%c%c",str[i],str[i+1],str[i+2],'\n');
              tagLevel++;
              i+=3;
          }
          else{
              tagLevel--;
              for(int j = 0; j< tagLevel*2; j++){
                  printf(" ");
              }
              printf("%c%c%c%c%c",str[i],str[i+1],str[i+2],str[i+3],'\n');
              i+=4;
          }
      }

  }
  indentedStr[textIndex] = 0;
  scanf("%d",&textIndex);
  return 0;
}

bool tagStart(int index){
    return str[index+1] != '/';
}
bool tagEnd(int index){
    return !tagStart(index);
}


#include<stdio.h>
#include<string.h>
bool tagStart(int);
bool tagEnd(int);
char indentedStr[4000];
char str[1000];
int main(){
  gets(str);
  int i =0;
  int tagLevel = 0;
  int textIndex = 0;
  for(;str[i]!=0;){
      if(str[i]=='<'){
          if(tagStart(i)){

              for(int j = 0; j< tagLevel*2; j++){
                  printf(" ");
              }
              printf("%c%c%c%c\n",str[i],str[i+1],str[i+2]);
              tagLevel++;
              i+=3;
          }
          else{
              tagLevel--;
              for(int j = 0; j< tagLevel*2; j++){
                  printf(" ");
              }
              printf("%c%c%c%c\n",str[i],str[i+1],str[i+2],str[i+3]);
              i+=4;
          }
      }

  }
  indentedStr[textIndex] = 0;
  scanf("%d",&textIndex);
  return 0;
}

bool tagStart(int index){
    return str[index+1] != '/';
}
bool tagEnd(int index){
    return !tagStart(index);
}


#pragma GCC optimize ("O2")
#pragma comment(linker, "/STACK:16777216")
#include <functional>
#include <algorithm>
#include <stdexcept>
#include <iostream>
#include <sstream>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <cctype>
#include <vector>
#include <string>
#include <bitset>
#include <cmath>
#include <queue>
#include <stack>
#include <ctime>
#include <list>
#include <map>
#include <set>

using namespace std;

#define rep(i,a,b) for(int i=a;i<b;++i)
#define repd(i,a,b) for(int i=a,_b=b;i>_b;--i)
#define sz size()
#define pb(x) push_back(x)
#define TEST freopen("in","r",stdin);
typedef long long ll;
const int N = 13;
const int INF = 0x3f3f3f3f;

string s;

int main() {
    while (cin >> s) {
        int tab = 0;
        int len = s.length();

        rep(i, 0, len) {
            string temp = "";
            while (i < len && s[i] != '>') {
                temp += s[i];
                ++i;
            }
            temp += s[i];
            if (temp.length() == 3) {
                rep(i, 0, tab) cout << "  ";
                cout << temp << endl;
                ++tab;
            } else {
                --tab;
                rep(i, 0, tab) cout << "  ";
                cout << temp << endl;
            }
        }
    }
}


#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
using namespace std;

#define PB push_back
#define MP make_pair

#define rep(i,n) for(int i=0;i<(n);++i)
#define REP(i,n) for(int i=1;i<=(n);++i)
#define FOR(i,l,h) for(int i=(l);i<=(h);++i)
#define FORD(i,h,l) for(int i=(h);i>=(l);--i)
#define print(expr) cout<<(#expr)<<" : "<<(expr)<<endl

typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<double> VD;
typedef long long int64;
typedef pair<int,int> pii;

string s1,s2;
string str;

int main(void)
{
	cin>>s1;
	rep(i,s1.size())
	{
		s2.PB(s1[i]);
		if(s1[i]=='>') s2.PB(' ');
	}
	istringstream in(s2);
	int sp=0;
	while(in>>str)
	{
		if(str[1]!='/')
		{
			rep(i,sp) cout<<' ';
			cout<<str<<endl;
			sp+=2;
		}
		else
		{
			sp-=2;
			rep(i,sp) cout<<' ';
			cout<<str<<endl;
		}
	}
}


#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<algorithm>
using namespace std;

int main()
{
    int a=0,b=0,n,arr[26],i,j,k,h;
    char str[1001];
    //freopen("fin.txt","r",stdin);
    scanf("%s",&str);
    n=strlen(str);
    j=1;
    h=0;
    for(i=0;i<(n/7*2);i++)
    {
        if(str[j]=='/')
        {
            h--;
            for(k=0;k<arr[str[j+1]-97];k++)
                printf(" ");
            printf("%c%c%c%c\n",str[j-1],str[j],str[j+1],str[j+2]);
            j+=4;
        }
        else
        {
            arr[str[j]-97]=2*h;
            h++;
            for(k=0;k<arr[str[j]-97];k++)
                printf(" ");
            printf("%c%c%c\n",str[j-1],str[j],str[j+1]);
            j+=3;
        }
    }
return 0;

}


#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<algorithm>
using namespace std;

int main()
{
    int a=0,b=0,n,arr[25],i,j,k,h;
    char str[1001];
    //freopen("fin.txt","r",stdin);
    scanf("%s",&str);
    n=strlen(str);
    j=1;
    h=0;
    for(i=0;i<(n/7*2);i++)
    {
        if(str[j]=='/')
        {
            h--;
            for(k=0;k<arr[str[j+1]-97];k++)
                printf(" ");
            printf("%c%c%c%c\n",str[j-1],str[j],str[j+1],str[j+2]);
            j+=4;
        }
        else
        {
            arr[str[j]-97]=2*h;
            h++;
            for(k=0;k<arr[str[j]-97];k++)
                printf(" ");
            printf("%c%c%c\n",str[j-1],str[j],str[j+1]);
            j+=3;
        }
    }
return 0;

}


#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<algorithm>
using namespace std;

int main()
{
    int a=0,b=0,n,i,j,k,h;
    char str[1001];
    //freopen("fin.txt","r",stdin);
    scanf("%s",&str);
    n=strlen(str);
    j=1;
    h=0;
    for(i=0;i<(n/7*2);i++)
    {
        if(str[j]=='/')
        {
            h--;
            for(k=0;k<2*h;k++)
                printf(" ");
            printf("%c%c%c%c\n",str[j-1],str[j],str[j+1],str[j+2]);
            j+=4;
        }
        else
        {
            for(k=0;k<2*h;k++)
                printf(" ");
            printf("%c%c%c\n",str[j-1],str[j],str[j+1]);
            j+=3;
            h++;
        }
    }
return 0;

}


#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<algorithm>
using namespace std;

int main()
{
    int a=0,b=0,n,i,j,k,h;
    char str[1001];
    //freopen("fin.txt","r",stdin);
    scanf("%s",&str);
    n=strlen(str);
    j=1;
    h=0;
    for(i=0;i<(n/7*2);i++)
    {
        if(str[j]=='/')
        {
            h--;
            for(k=0;k<2*h;k++)
                printf(" ");
            printf("%c%c%c%c\n",str[j-1],str[j],str[j+1],str[j+2]);
            j+=4;
        }
        else
        {
            arr[str[j]-97]=2*h;
            for(k=0;k<2*h;k++)
                printf(" ");
            printf("%c%c%c\n",str[j-1],str[j],str[j+1]);
            j+=3;
            h++;
        }
    }
return 0;

}


#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<set>
using namespace std;
string s,s1;
int q[100];
string bel;
set<char> st;
int main()
{
    int k1=0;
    cin>>s;
    s1=s;
    for(int i=0;i<s.length();i++)
    {
        if(s[i]!='<'&&s[i]!='>'&&s[i]!='/')
        {
            s1[k1]=s[i];
            k1++;
        }
    }
    s1.resize(k1);
    //cout<<s1;

    for(int i=0;i<k1;i++)
    {
        if(st.find(s1[i])==st.end())
        {
            st.insert(s1[i]);
        }
        else
        {
            q[i]++;
        }
    }
    q[-1]=q[0];
    int w=-1;
    //cout<<endl;
    for(int i=0;i<k1;i++)
    {
        if(q[i-1]==0&&q[i]==0) w++;

        if(q[i-1]==1&&q[i]==1) w--;

        if(q[i]==0) {for(int j=0;j<w;j++){cout<<"  ";} cout<<"<"<<s1[i]<<">"<<endl;  }

        if(q[i]==1) {for(int j=0;j<w;j++){cout<<"  ";} cout<<"</"<<s1[i]<<">"<<endl; }
    }

    cin>>s;
    return 0;
}


#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<set>
using namespace std;
string s,s1;
int q[100];
string bel;
set<char> st;
int main()
{
    int k1=0;
    cin>>s;
    s1=s;
    for(int i=0;i<s.length();i++)
    {
        if(s[i]!='<'&&s[i]!='>'&&s[i]!='/')
        {
            s1[k1]=s[i];
            k1++;
        }
    }
    s1.resize(k1);
    //cout<<s1;

    for(int i=0;i<k1;i++)
    {
        if(st.find(s1[i])==st.end())
        {
            st.insert(s1[i]);
        }
        else
        {
            q[i]++;
        }
    }
    q[-1]=q[0];
    int w=-1;
    cout<<endl;
    for(int i=0;i<k1;i++)
    {
        if(q[i-1]==0&&q[i]==0) w++;

        if(q[i-1]==1&&q[i]==1) w--;

        if(q[i]==0) {for(int j=0;j<w;j++){cout<<"  ";} cout<<"<"<<s1[i]<<">"<<endl;  }

        if(q[i]==1) {for(int j=0;j<w;j++){cout<<"  ";} cout<<"</"<<s1[i]<<">"<<endl; }
    }

    cin>>s;
    return 0;
}


#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<set>
using namespace std;
string s,s1;
int q[100],def[100];
string bel,ss;
set<char> st;
int ddd[100];
int main()
{
//  freopen("D:/input.txt","rt",stdin);
//  freopen("D:/output.txt","wt",stdout);
    int k1=0;
    cin>>s;
    s1=s;
    for(int i=0;i<s.length();i++)
    {
        if(s[i]!='<'&&s[i]!='>'&&s[i]!='/')
        {
            s1[k1]=s[i];
            k1++;
        }
    }
    s1.resize(k1);
    //cout<<s1;
    ss.resize(k1);
    int lenset=0;
    for(int i=0;i<k1;i++)
    {
        if(st.find(s1[i])==st.end())
        {
            st.insert(s1[i]); ss[lenset]=s1[i]; lenset++;
        }
        else
        {
    //  q[i]++;
    //  q[i]%=2;
        }
    }
    ss.resize(lenset);

    for(int i=0;i<k1;i++)
    {
        for(int j=0;j<lenset;j++)
        {
            if(s1[i]==ss[j])
            {
            q[i]+=ddd[j]; ddd[j]++;
            }
        }
        //q[i]++;
        q[i]%=2;
    }

    q[-1]=q[0];
    int w=-1;
    //cout<<endl;
    for(int i=0;i<k1;i++)
    {
        if(q[i-1]==0&&q[i]==0) w++;

        if(q[i-1]==1&&q[i]==1) w--;

        if(q[i]==0) {for(int j=0;j<w;j++){cout<<"  ";} cout<<"<"<<s1[i]<<">"<<endl;  }

        if(q[i]==1) {for(int j=0;j<w;j++){cout<<"  ";} cout<<"</"<<s1[i]<<">"<<endl; }
    }

    cin>>s;
    return 0;
}


#include <iostream>;
#include <math.h>;
#include <string>;

using namespace std;

void main()
{
    char xml[1000];

    for (int i=0; i<1000;i++){xml[i]='0';}

    int ur=0,kol,i=0;

    cin>>xml;

    while (xml[i]!='0'){i++;}
    i--;

    for (int j=0;j<i;j++)
    {
        if (xml[j+1]=='/'){ur-=2;}
        for (int a=0;a<ur;a++){cout<<" ";}
        if (xml[j+1]!='/'){cout<<xml[j]<<xml[j+1]<<xml[j+2]<<endl;j++;j++; ur+=2;}
        else{cout<<xml[j]<<xml[j+1]<<xml[j+2]<<xml[j+3]<<endl;j++;j++;j++; ur-=2;}
    }

}


#include <iostream>;
#include <math.h>;
#include <string>;

using namespace std;

void main()
{
    char xml[1000];

    for (int i=0; i<1000;i++){xml[i]='0';}

    int ur=0,kol,i=0;

    cin>>xml;

    while (xml[i]!='0'){i++;}
    i--;

    for (int j=0;j<i;j++)
    {
        if (xml[j+1]=='/'){ur-=2;}
        for (int a=0;a<ur;a++){cout<<" ";}
        if (xml[j+1]!='/'){cout<<xml[j]<<xml[j+1]<<xml[j+2]<<endl;j++;j++; ur+=2;}
        else{cout<<xml[j]<<xml[j+1]<<xml[j+2]<<xml[j+3]<<endl;j++;j++;j++; }
    }

}


#include <iostream>
#include <string>
using namespace std;

void out(int k)
{
	for(int i=0;i<2*k;i++)
		cout << " ";
}

int main()
{
	string s;
	cin >> s;
	int depth = 0;
	for(int i=0;i<s.size();)
	{
		if(s[i+1]=='/')
		{
			out(--depth);
			cout << "</" << s[i+2] << ">" << endl;
			i += 4;
		}
		else
		{
			out(depth++);
			cout << "<" << s[i+1] << ">" << endl;
			i += 3;
		}
	}
}


/*   In The Name of Allah   */

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std ;

typedef long long LL ;
#define ALL(a)              (a).begin(),(a).end()
#define SZ(v)               ((int)(v).size())
#define FOR(i,start,end)    for(int i = start ; i < end ; i++)
#define REP(i,start,end)    for(int i = start ; i >= end ; i--)
#define FOREACH(it,x)       for(it = (x.begin()) ; it != (x).end() ; it ++)

bool isLowerCase(char c){ return (c >= 'a' &&  c <= 'z') ; }
bool isUpperCase(char c){ return (c >= 'A' &&  c <= 'Z') ; }
char toLowerCase(char c){ return (isUpperCase(c) ? (c + 32) : c) ; }
char toUpperCase(char c){ return (isLowerCase(c) ? (c - 32) : c) ; }
bool isLetter ( char c ){ return (isUpperCase(c)) || (isLowerCase(c)) ; }
bool isDigit  ( char c ){ return (c >= '0' &&  c <= '9') ; }

int main()// test 2 - B. Simple XML
{
    //freopen ("input.in","r",stdin) ; //freopen ("output.out","w",stdout) ;
    //ifstream cin("input.in") ; //ofstream cout("output.out") ;

    string s ; cin >> s ;

    vector < pair < char , int > > vs ;
    map < char , int > m ;
    FOR(i , 0 , SZ(s)){
        if(isLetter(s[i])){
            vs.push_back(make_pair(s[i] , 0)) ;
            m[s[i]] ++ ;
        }
    }

    int index = 0 ;
    stack < char > st ;
    FOR(i , 0 , SZ(vs)){
        if(SZ(st) > 0 && st.top() == vs[i].first){
            --index ;
            vs[i].second = index ;
            st.pop() ;
        }
        else{
            st.push(vs[i].first) ;
            vs[i].second = index ;
            ++index ;
        }
    }// end of for(i)

    FOR(i , 0 , SZ(vs)){
        string space(2 * vs[i].second , ' ') ;
        if(m[vs[i].first] == 2){
            m[vs[i].first] -- ;
            cout << space << "<" << vs[i].first << ">\n" ;
        }
        else if(m[vs[i].first] == 1){
            cout << space << "</" << vs[i].first << ">\n" ;
        }
    }

return 0 ;
}
/*
---------------------------------------------
Input:
---------

---------------------------------------------
Output:
---------

---------------------------------------------
*/


/*   In The Name of Allah   */

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std ;

typedef long long LL ;
#define ALL(a)              (a).begin(),(a).end()
#define SZ(v)               ((int)(v).size())
#define FOR(i,start,end)    for(int i = start ; i < end ; i++)
#define REP(i,start,end)    for(int i = start ; i >= end ; i--)
#define FOREACH(it,x)       for(it = (x.begin()) ; it != (x).end() ; it ++)

template < class T > string toString(T x) {stringstream s ; s << x; return s.str() ; }
template < class T > long long toInt(T x) {istringstream is(x) ; long long num  ; is >> num ; return num ; }

bool isLowerCase(char c){ return (c >= 'a' &&  c <= 'z') ; }
bool isUpperCase(char c){ return (c >= 'A' &&  c <= 'Z') ; }
char toLowerCase(char c){ return (isUpperCase(c) ? (c + 32) : c) ; }
char toUpperCase(char c){ return (isLowerCase(c) ? (c - 32) : c) ; }
bool isLetter ( char c ){ return (isUpperCase(c)) || (isLowerCase(c)) ; }
bool isDigit  ( char c ){ return (c >= '0' &&  c <= '9') ; }

int main()// test 2 - B. Simple XML
{
    //freopen ("input.in","r",stdin) ; //freopen ("output.out","w",stdout) ;
    //ifstream cin("input.in") ; //ofstream cout("output.out") ;

    string s ; cin >> s ;

    vector < pair < string , int > > vs ;
    stack < string > st ;
    FOR(i , 0 , SZ(s)){
        if(i > 0 && isLetter(s[i]) && s[i - 1]=='/'){
            vs.push_back(make_pair(toString("/" + toString(s[i])) , 0)) ;
        }
        else if(isLetter(s[i])){
            vs.push_back(make_pair(toString(s[i]) , -1)) ;
        }
    }// end of for(i)

    int index = 0;
    FOR(i , 0 , SZ(vs)){
        string t1 , t2 ;
        if(SZ(st) > 0 && SZ(vs[i].first) == 2){
            t1 = st.top() ;
            t2 = vs[i].first ;
            if(SZ(t2) == 2 && t2[1] == t1[0]){
                --index ;
                vs[i].second = index ;
                st.pop() ;
            }
        }
        else{
            st.push(vs[i].first) ;
            vs[i].second = index ;
            ++index ;
        }
    }// end of for(i)

    FOR(i , 0 , SZ(vs)){
        string space(2 * vs[i].second , ' ') ;
        cout << space << "<" << vs[i].first << ">\n" ;
    }// end of for(i)

return 0 ;
}
/*
---------------------------------------------
Input:
---------

---------------------------------------------
Output:
---------

---------------------------------------------
*/


#include <iostream>
#include <cstdio>
#include <string>
#include <sstream>
#include <algorithm>
#include <set>
#include <numeric>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <cstring>
#include <queue>
#include <numeric>
#include <iomanip>
#define ll long long
using namespace std;
const long long MAXN = 300001;
long long color[MAXN];
long long arr[MAXN];
long long l,r,x,n,m;
set<pair<long long,long long> > segment;
struct segTree{
    vector<long long > tree,lazy,mn;
    void init(long long n){
        tree.resize(4*n+1,0); lazy.resize(4*n+1,0); mn.resize(4*n+1,0);
    }
    void push(long long node,long long st,long long ed){
        tree[node]+=(lazy[node]*(ed-st+1));
        mn[node]+=lazy[node];
        if(st!=ed){lazy[node*2]+=lazy[node]; lazy[node*2+1]+=lazy[node];}
        lazy[node]=0;
    }
    void update(long long node,long long st,long long ed,long long l,long long r,ll val){
        push(node,st,ed);
        if(st> r || ed<l)return;
        if(st>=l && ed<=r){
            lazy[node]+=val; push(node,st,ed);
            return;
        }
        update(node*2,st,(st+ed)/2,l,r,val);
        update(node*2+1,(st+ed)/2+1,ed,l,r,val);
        tree[node] = tree[node*2]+tree[node*2+1];
        mn[node] =min(mn[node*2],mn[node*2+1]);
    }
    pair<ll,ll> query(long long node,long long st,long long ed,long long l,long long r){ //first min, sum
        push(node,st,ed);
        if(st>r || ed<l)return {1e18,0}; //에러 나면 make_pair 함해보기 , 1e18이 충분히큰가 생각해보기
        if(st>=l && ed<=r)
            return {mn[node],tree[node]};
        auto L = query(node*2,st,(st+ed)/2,l,r);
        auto R = query(node*2+1,(st+ed)/2+1,ed,l,r);
        return make_pair(min(L.first,R.first),L.second+R.second);
    }
}seg;
void relax1(long long pos){
    //pos를 포함하는 구간을 찾아야됨
    auto it = segment.lower_bound(make_pair(pos,pos));
    if(it->first > pos) it--;
    if(it->first == pos) return;

    pair<long long,long long> p1 = make_pair(it->first,pos-1);
    pair<long long,long long> p2 = make_pair(pos,it->second);
    color[pos] = color[it->first];
    segment.erase(it);
    segment.insert(p1); segment.insert(p2);
}
void relax2(long long pos){
    auto it = segment.lower_bound(make_pair(pos,pos));
    if(it->first > pos) it--;
    if(it->second == pos) return;
    pair<long long,long long> p1 = make_pair(it->first,pos);
    pair<long long,long long> p2 = make_pair(pos+1,it->second);
    color[pos+1] = color[it->first];
    segment.erase(it);
    segment.insert(p1); segment.insert(p2);
}
int main(){
    ios::sync_with_stdio(false); cin.tie(0);
    long long n,q; cin>>n>>q;
    seg.init(n);
    int cnt = 0;
    for(long long i=1;i<=n;i++) segment.insert({i,i});
    for(long long i=1;i<=n;i++) color[i] = i;

    for(long long i=1;i<=q;i++){
        long long cmd,l,r,x; cin>>cmd>>l>>r;
        if(cmd == 1){
            cin>>x;
            relax1(l); relax2(r);
            auto it = segment.lower_bound({l,l});
            for(;;){
                cnt++;
                if(cnt>150000){

                    cout<<-1;
                    exit(0);
                    break;
                }
                auto jt = it; jt++;
                long long f = it->first;
                long long s = it->second;
                seg.update(1,1,n,it->first,it->second,abs(color[f]-x));
                segment.erase(it);
                it = jt;
                if(s == r)break;
            }
            segment.insert(make_pair(l,r));
            color[l] = x;
        }
        else{
            cout<<seg.query(1,1,n,l,r).second<<"\n";
        }
    }

    return 0;
}


#include <iostream>
#include <cstdio>
#include <string>
#include <sstream>
#include <algorithm>
#include <set>
#include <numeric>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <cstring>
#include <queue>
#include <numeric>
#include <iomanip>
#define ll long long
using namespace std;
const long long MAXN = 300001;
long long color[MAXN];
long long arr[MAXN];
long long l,r,x,n,m;
set<pair<long long,long long> > segment;
struct segTree{
    vector<long long > tree,lazy,mn;
    void init(long long n){
        tree.resize(4*n+1,0); lazy.resize(4*n+1,0); mn.resize(4*n+1,0);
    }
    void push(long long node,long long st,long long ed){
        tree[node]+=(lazy[node]*(ed-st+1));
        mn[node]+=lazy[node];
        if(st!=ed){lazy[node*2]+=lazy[node]; lazy[node*2+1]+=lazy[node];}
        lazy[node]=0;
    }
    void update(long long node,long long st,long long ed,long long l,long long r,ll val){
        push(node,st,ed);
        if(st> r || ed<l)return;
        if(st>=l && ed<=r){
            lazy[node]+=val; push(node,st,ed);
            return;
        }
        update(node*2,st,(st+ed)/2,l,r,val);
        update(node*2+1,(st+ed)/2+1,ed,l,r,val);
        tree[node] = tree[node*2]+tree[node*2+1];
        mn[node] =min(mn[node*2],mn[node*2+1]);
    }
    pair<ll,ll> query(long long node,long long st,long long ed,long long l,long long r){ //first min, sum
        push(node,st,ed);
        if(st>r || ed<l)return {1e18,0}; //에러 나면 make_pair 함해보기 , 1e18이 충분히큰가 생각해보기
        if(st>=l && ed<=r)
            return {mn[node],tree[node]};
        auto L = query(node*2,st,(st+ed)/2,l,r);
        auto R = query(node*2+1,(st+ed)/2+1,ed,l,r);
        return make_pair(min(L.first,R.first),L.second+R.second);
    }
}seg;
void relax1(long long pos){
    //pos를 포함하는 구간을 찾아야됨
    auto it = segment.lower_bound(make_pair(pos,pos));
    if(it->first > pos) it--;
    if(it->first == pos) return;

    pair<long long,long long> p1 = make_pair(it->first,pos-1);
    pair<long long,long long> p2 = make_pair(pos,it->second);
    color[pos] = color[it->first];
    segment.erase(it);
    segment.insert(p1); segment.insert(p2);
}
void relax2(long long pos){
    auto it = segment.lower_bound(make_pair(pos,pos));
    if(it->first > pos) it--;
    if(it->second == pos) return;

    pair<long long,long long> p1 = make_pair(it->first,pos);
    pair<long long,long long> p2 = make_pair(pos+1,it->second);
    color[pos+1] = color[it->first];
    segment.erase(it);
    segment.insert(p1); segment.insert(p2);
}
int main(){
    ios::sync_with_stdio(false); cin.tie(0);
    long long n,q; cin>>n>>q;
    seg.init(n);
    for(long long i=1;i<=n;i++) segment.insert({i,i});
    for(long long i=1;i<=n;i++) color[i] = i;
    for(long long i=1;i<=q;i++){
        long long cmd,l,r,x; cin>>cmd>>l>>r;
        if(cmd == 1){
            cin>>x;
            relax1(l); relax2(r);
            auto it = segment.lower_bound({l,l});
            for(;;){
                auto jt = it; jt++;
                long long f = it->first;
                long long s = it->second;
                seg.update(1,1,n,it->first,it->second,abs(color[f]-x));
                segment.erase(it);
                it = jt;
                if(s == r)break;
            }
            segment.insert(make_pair(l,r));
            color[l] = x;
        }
        else{
            cout<<seg.query(1,1,n,l,r).second<<"\n";
        }
    }

    return 0;
}


#include <iostream>
#include <cstdio>
#include <string>
#include <sstream>
#include <algorithm>
#include <set>
#include <numeric>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <cstring>
#include <queue>
#include <numeric>
#include <iomanip>
#define ll long long
using namespace std;
set<pair<long long,long long> > segment;
const long long MAXN = 300001;
long long color[MAXN];
#include <vector>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <string>
#define ll long long
using namespace std;
long long arr[MAXN];
int l,r,x,n,m;
struct segTree{
    vector<long long > tree,lazy,mn;
    void init(int n){
        tree.resize(4*n+1,0); lazy.resize(4*n+1,0); mn.resize(4*n+1,0);
    }
    void push(int node,int st,int ed){
        tree[node]+=(lazy[node]*(ed-st+1));
        mn[node]+=lazy[node];
        if(st!=ed){lazy[node*2]+=lazy[node]; lazy[node*2+1]+=lazy[node];}
        lazy[node]=0;
    }
    void update(int node,int st,int ed,int l,int r,ll val){
        push(node,st,ed);
        if(st> r || ed<l)return;
        if(st>=l && ed<=r){
            lazy[node]+=val; push(node,st,ed);
            return;
        }
        update(node*2,st,(st+ed)/2,l,r,val);
        update(node*2+1,(st+ed)/2+1,ed,l,r,val);
        tree[node] = tree[node*2]+tree[node*2+1];
        mn[node] =min(mn[node*2],mn[node*2+1]);
    }
    pair<ll,ll> query(int node,int st,int ed,int l,int r){ //first min, sum
        push(node,st,ed);
        if(st>r || ed<l)return {1e18,0}; //에러 나면 make_pair 함해보기 , 1e18이 충분히큰가 생각해보기
        if(st>=l && ed<=r)
            return {mn[node],tree[node]};
        auto L = query(node*2,st,(st+ed)/2,l,r);
        auto R = query(node*2+1,(st+ed)/2+1,ed,l,r);
        return make_pair(min(L.first,R.first),L.second+R.second);
    }
}seg;
void relax1(long long pos){
    //pos를 포함하는 구간을 찾아야됨
    auto it = segment.lower_bound(make_pair(pos,pos));
    if(it->first == pos) return;
    if(it->first > pos) it--;
    pair<long long,long long> p1 = make_pair(it->first,pos-1);
    pair<long long,long long> p2 = make_pair(pos,it->second);
    color[pos] = color[it->second] = color[pos-1] = color[it->first];
    segment.erase(it);
    segment.insert(p1); segment.insert(p2);
}
void relax2(long long pos){
    auto it = segment.lower_bound(make_pair(pos,pos));
    if(it->second == pos) return;
    if(it->first > pos) it--;
    pair<long long,long long> p1 = make_pair(it->first,pos);
    pair<long long,long long> p2 = make_pair(pos+1,it->second);
    color[pos] = color[it->second] = color[pos+1] = color[it->first];
    segment.erase(it);
    segment.insert(p1); segment.insert(p2);
}
int main(){
    long long n,q; cin>>n>>q;
    seg.init(n);
    for(long long i=1;i<=n;i++) segment.insert({i,i});
    for(long long i=1;i<=n;i++) color[i] = i;
    for(long long i=1;i<=q;i++){
        long long cmd,l,r,x; cin>>cmd>>l>>r;
        if(cmd == 1){
            cin>>x;
            relax1(l); relax2(r);
            auto it = segment.lower_bound({l,l});
            for(;;){
                auto jt = it; jt++;
                long long f = it->first;
                long long s = it->second;
                seg.update(1,1,n,it->first,it->second,abs(color[f]-x));
                color[it->first] = x;
                segment.erase(it);
                it = jt;
                if(s == r)break;
            }
            segment.insert(make_pair(l,r));
            color[l] = x; color[r] = x;
        }
        else{
            cout<<seg.query(1,1,n,l,r).second<<"\n";
        }
    }

    return 0;
}


#include <iostream>
#include <cstdio>
#include <string>
#include <sstream>
#include <algorithm>
#include <set>
#include <numeric>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <cstring>
#include <queue>
#include <numeric>
#include <iomanip>
#define ll long long
using namespace std;
const long long MAXN = 300001;
long long color[MAXN];
long long arr[MAXN];
long long l,r,x,n,m;
set<pair<long long,long long> > segment;
struct segTree{
    vector<long long > tree,lazy,mn;
    void init(long long n){
        tree.resize(4*n+1,0); lazy.resize(4*n+1,0); mn.resize(4*n+1,0);
    }
    void push(long long node,long long st,long long ed){
        tree[node]+=(lazy[node]*(ed-st+1));
        mn[node]+=lazy[node];
        if(st!=ed){lazy[node*2]+=lazy[node]; lazy[node*2+1]+=lazy[node];}
        lazy[node]=0;
    }
    void update(long long node,long long st,long long ed,long long l,long long r,ll val){
        push(node,st,ed);
        if(st> r || ed<l)return;
        if(st>=l && ed<=r){
            lazy[node]+=val; push(node,st,ed);
            return;
        }
        update(node*2,st,(st+ed)/2,l,r,val);
        update(node*2+1,(st+ed)/2+1,ed,l,r,val);
        tree[node] = tree[node*2]+tree[node*2+1];
        mn[node] =min(mn[node*2],mn[node*2+1]);
    }
    pair<ll,ll> query(long long node,long long st,long long ed,long long l,long long r){ //first min, sum
        push(node,st,ed);
        if(st>r || ed<l)return {1e18,0}; //에러 나면 make_pair 함해보기 , 1e18이 충분히큰가 생각해보기
        if(st>=l && ed<=r)
            return {mn[node],tree[node]};
        auto L = query(node*2,st,(st+ed)/2,l,r);
        auto R = query(node*2+1,(st+ed)/2+1,ed,l,r);
        return make_pair(min(L.first,R.first),L.second+R.second);
    }
}seg;
void relax1(long long pos){
    //pos를 포함하는 구간을 찾아야됨
    auto it = segment.lower_bound(make_pair(pos,pos));
    if(it->first > pos) it--;
    if(it->first == pos) return;

    pair<long long,long long> p1 = make_pair(it->first,pos-1);
    pair<long long,long long> p2 = make_pair(pos,it->second);
    color[pos] = color[it->first];
    segment.erase(it);
    segment.insert(p1); segment.insert(p2);
}
void relax2(long long pos){
    auto it = segment.lower_bound(make_pair(pos,pos));
    if(it->first > pos) it--;
    if(it->second == pos) return;
    pair<long long,long long> p1 = make_pair(it->first,pos);
    pair<long long,long long> p2 = make_pair(pos+1,it->second);
    color[pos+1] = color[it->first];
    segment.erase(it);
    segment.insert(p1); segment.insert(p2);
}
int main(){
    ios::sync_with_stdio(false); cin.tie(0);
    long long n,q; cin>>n>>q;
    seg.init(n);
    int cnt = 0;
    for(long long i=1;i<=n;i++) segment.insert({i,i});
    for(long long i=1;i<=n;i++) color[i] = i;

    for(long long i=1;i<=q;i++){
        long long cmd,l,r,x; cin>>cmd>>l>>r;
        if(cmd == 1){
            cin>>x;
            relax1(l); relax2(r);
            auto it = segment.lower_bound({l,l});
            for(;;){
                cnt++;
                if(cnt>1000000){

                    cout<<-1;
                    exit(0);
                    break;
                }
                auto jt = it; jt++;
                long long f = it->first;
                long long s = it->second;
                seg.update(1,1,n,it->first,it->second,abs(color[f]-x));
                segment.erase(it);
                it = jt;
                if(s == r)break;
            }
            segment.insert(make_pair(l,r));
            color[l] = x;
        }
        else{
            cout<<seg.query(1,1,n,l,r).second<<"\n";
        }
    }

    return 0;
}


#include <iostream>
#include <cstdio>
#include <string>
#include <sstream>
#include <algorithm>
#include <set>
#include <numeric>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <cstring>
#include <queue>
#include <numeric>
#include <iomanip>
#define ll long long
using namespace std;
const long long MAXN = 300001;
long long color[MAXN];
long long arr[MAXN];
long long l,r,x,n,m;
set<pair<long long,long long> > segment;
struct segTree{
    vector<long long > tree,lazy,mn;
    void init(long long n){
        tree.resize(4*n+1,0); lazy.resize(4*n+1,0); mn.resize(4*n+1,0);
    }
    void push(long long node,long long st,long long ed){
        tree[node]+=(lazy[node]*(ed-st+1));
        mn[node]+=lazy[node];
        if(st!=ed){lazy[node*2]+=lazy[node]; lazy[node*2+1]+=lazy[node];}
        lazy[node]=0;
    }
    void update(long long node,long long st,long long ed,long long l,long long r,ll val){
        push(node,st,ed);
        if(st> r || ed<l)return;
        if(st>=l && ed<=r){
            lazy[node]+=val; push(node,st,ed);
            return;
        }
        update(node*2,st,(st+ed)/2,l,r,val);
        update(node*2+1,(st+ed)/2+1,ed,l,r,val);
        tree[node] = tree[node*2]+tree[node*2+1];
        mn[node] =min(mn[node*2],mn[node*2+1]);
    }
    pair<ll,ll> query(long long node,long long st,long long ed,long long l,long long r){ //first min, sum
        push(node,st,ed);
        if(st>r || ed<l)return {1e18,0}; //에러 나면 make_pair 함해보기 , 1e18이 충분히큰가 생각해보기
        if(st>=l && ed<=r)
            return {mn[node],tree[node]};
        auto L = query(node*2,st,(st+ed)/2,l,r);
        auto R = query(node*2+1,(st+ed)/2+1,ed,l,r);
        return make_pair(min(L.first,R.first),L.second+R.second);
    }
}seg;
void relax1(long long pos){
    //pos를 포함하는 구간을 찾아야됨
    auto it = segment.lower_bound(make_pair(pos,pos));
    if(it->first > pos) it--;
    if(it->first == pos) return;

    pair<long long,long long> p1 = make_pair(it->first,pos-1);
    pair<long long,long long> p2 = make_pair(pos,it->second);
    color[pos] = color[it->first];
    segment.erase(it);
    segment.insert(p1); segment.insert(p2);
}
void relax2(long long pos){
    auto it = segment.lower_bound(make_pair(pos,pos));
    if(it->first > pos) it--;
    if(it->second == pos) return;

    pair<long long,long long> p1 = make_pair(it->first,pos);
    pair<long long,long long> p2 = make_pair(pos+1,it->second);
    color[pos+1] = color[it->first];
    segment.erase(it);
    segment.insert(p1); segment.insert(p2);
}
int main(){
    long long n,q; cin>>n>>q;
    seg.init(n);
    for(long long i=1;i<=n;i++) segment.insert({i,i});
    for(long long i=1;i<=n;i++) color[i] = i;
    for(long long i=1;i<=q;i++){
        long long cmd,l,r,x; cin>>cmd>>l>>r;
        if(cmd == 1){
            cin>>x;
            relax1(l); relax2(r);
            auto it = segment.lower_bound({l,l});
            for(;;){
                auto jt = it; jt++;
                long long f = it->first;
                long long s = it->second;
                seg.update(1,1,n,it->first,it->second,abs(color[f]-x));
                segment.erase(it);
                it = jt;
                if(s == r)break;
            }
            segment.insert(make_pair(l,r));
            color[l] = x;
        }
        else{
            cout<<seg.query(1,1,n,l,r).second<<"\n";
        }
    }

    return 0;
}


#include <iostream>
#include <cstdio>
#include <string>
#include <sstream>
#include <algorithm>
#include <set>
#include <numeric>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <cstring>
#include <queue>
#include <numeric>
#include <iomanip>
#define ll long long
using namespace std;
const long long MAXN = 300001;
long long color[MAXN];
long long arr[MAXN];
long long l,r,x,n,m;
set<pair<long long,long long> > segment;
struct segTree{
    vector<long long > tree,lazy,mn;
    void init(long long n){
        tree.resize(4*n+1,0); lazy.resize(4*n+1,0); mn.resize(4*n+1,0);
    }
    void push(long long node,long long st,long long ed){
        tree[node]+=(lazy[node]*(ed-st+1));
        mn[node]+=lazy[node];
        if(st!=ed){lazy[node*2]+=lazy[node]; lazy[node*2+1]+=lazy[node];}
        lazy[node]=0;
    }
    void update(long long node,long long st,long long ed,long long l,long long r,ll val){
        push(node,st,ed);
        if(st> r || ed<l)return;
        if(st>=l && ed<=r){
            lazy[node]+=val; push(node,st,ed);
            return;
        }
        update(node*2,st,(st+ed)/2,l,r,val);
        update(node*2+1,(st+ed)/2+1,ed,l,r,val);
        tree[node] = tree[node*2]+tree[node*2+1];
        mn[node] =min(mn[node*2],mn[node*2+1]);
    }
    pair<ll,ll> query(long long node,long long st,long long ed,long long l,long long r){ //first min, sum
        push(node,st,ed);
        if(st>r || ed<l)return {1e18,0}; //에러 나면 make_pair 함해보기 , 1e18이 충분히큰가 생각해보기
        if(st>=l && ed<=r)
            return {mn[node],tree[node]};
        auto L = query(node*2,st,(st+ed)/2,l,r);
        auto R = query(node*2+1,(st+ed)/2+1,ed,l,r);
        return make_pair(min(L.first,R.first),L.second+R.second);
    }
}seg;
void relax1(long long pos){
    //pos를 포함하는 구간을 찾아야됨
    auto it = segment.lower_bound(make_pair(pos,pos));
    if(it->first > pos) it--;
    if(it->first == pos) return;

    pair<long long,long long> p1 = make_pair(it->first,pos-1);
    pair<long long,long long> p2 = make_pair(pos,it->second);
    color[pos] = color[it->first];
    segment.erase(it);
    segment.insert(p1); segment.insert(p2);
}
void relax2(long long pos){
    auto it = segment.lower_bound(make_pair(pos,pos));
    if(it->first > pos) it--;
    if(it->second == pos) return;
    pair<long long,long long> p1 = make_pair(it->first,pos);
    pair<long long,long long> p2 = make_pair(pos+1,it->second);
    color[pos+1] = color[it->first];
    segment.erase(it);
    segment.insert(p1); segment.insert(p2);
}
int main(){
    ios::sync_with_stdio(false); cin.tie(0);
    long long n,q; cin>>n>>q;
    seg.init(n);
    int cnt = 0;
    for(long long i=1;i<=n;i++) segment.insert({i,i});
    for(long long i=1;i<=n;i++) color[i] = i;

    for(long long i=1;i<=q;i++){
        long long cmd,l,r,x; cin>>cmd>>l>>r;
        if(cmd == 1){
            cin>>x;
            relax1(l); relax2(r);
            auto it = segment.lower_bound({l,l});
            for(;;){
                cnt++;
                if(cnt>500000){

                    cout<<-1;
                    exit(0);
                    break;
                }
                auto jt = it; jt++;
                long long f = it->first;
                long long s = it->second;
                seg.update(1,1,n,it->first,it->second,abs(color[f]-x));
                segment.erase(it);
                it = jt;
                if(s == r)break;
            }
            segment.insert(make_pair(l,r));
            color[l] = x;
        }
        else{
            cout<<seg.query(1,1,n,l,r).second<<"\n";
        }
    }

    return 0;
}


#include <vector>
#include <iostream>
#include <set>
#include <cstring>
#include <algorithm>
#include <string>
#define ll long long
using namespace std;
const int MAXN=200001;
long long arr[MAXN];
int l,r,x,n,m;
struct segTree{
    vector<long long > tree,lazy,mn;
    void init(int n){
        tree.resize(4*n+1,0); lazy.resize(4*n+1,0); mn.resize(4*n+1,0);
    }
    void push(int node,int st,int ed){
        tree[node]+=(lazy[node]*(ed-st+1));
        mn[node]+=lazy[node];
        if(st!=ed){lazy[node*2]+=lazy[node]; lazy[node*2+1]+=lazy[node];}
        lazy[node]=0;
    }
    void update(int node,int st,int ed,int l,int r,ll val){
        push(node,st,ed);
        if(st> r || ed<l)return;
        if(st>=l && ed<=r){
            lazy[node]+=val; push(node,st,ed);
            return;
        }
        update(node*2,st,(st+ed)/2,l,r,val);
        update(node*2+1,(st+ed)/2+1,ed,l,r,val);
        tree[node] = tree[node*2]+tree[node*2+1];
        mn[node] =min(mn[node*2],mn[node*2+1]);
    }
    pair<ll,ll> query(int node,int st,int ed,int l,int r){ //first min, sum
        push(node,st,ed);
        if(st>r || ed<l)return {1e18,0}; //에러 나면 make_pair 함해보기 , 1e18이 충분히큰가 생각해보기
        if(st>=l && ed<=r)
            return {mn[node],tree[node]};
        auto L = query(node*2,st,(st+ed)/2,l,r);
        auto R = query(node*2+1,(st+ed)/2+1,ed,l,r);
        return make_pair(min(L.first,R.first),L.second+R.second);
    }
}seg;
struct block{
    int s,e,clr;
    bool operator < (const block b)const{
        return s<b.s;
    }
};
set<block> segment;
void relax1(int pos){
    auto it = segment.lower_bound({pos,pos,-1});
    if(it == segment.end() || it->s > pos) it--;
    if(it->s == pos)return;
    block t1 = {it->s,pos-1,it->clr};
    block t2 = {pos,it->e,it->clr};
    segment.erase(it); segment.insert(t1);  segment.insert(t2);
}
void relax2(int pos){
    auto it = segment.lower_bound({pos,pos,-1});
    if(it == segment.end() || it->s > pos) it--;
    if(it->e == pos)return;
    block t1 = {it->s,pos,it->clr};
    block t2 = {pos+1,it->e,it->clr};
    segment.erase(it); segment.insert(t1); segment.insert(t2);
}
int main(){
    ios::sync_with_stdio(false); cin.tie(0);
    cin>>n>>m;
    seg.init(n);
    for(int i=1;i<=n;i++){
        segment.insert({i,i,i});
    }
    for(int i=1;i<=m;i++){
        int cmd,l,r,x;
        cin>>cmd>>l>>r;
        if(cmd == 1){
            cin>>x;
            relax1(l); relax2(r);
            auto it = segment.lower_bound({l,l,-1});
            bool ed = false;
            for(;;){
                auto jt = it; jt++;
                if(it->e == r)ed = true;
                block temp = {it->s,it->e,x};
                seg.update(1,1,n,it->s,it->e,(abs(x-it->clr)));
                segment.erase(it);
                segment.insert(temp);
                it = jt;
                if(ed)break;
            }
        }
        else{
            cout<<seg.query(1,1,n,l,r).second<<"\n";
        }
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <string>
#include <sstream>
#include <algorithm>
#include <set>
#include <numeric>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <cstring>
#include <queue>
#include <numeric>
#include <iomanip>
#define ll long long
using namespace std;
const long long MAXN = 300001;
long long color[MAXN];
long long arr[MAXN];
long long l,r,x,n,m;
set<pair<long long,long long> > segment;
struct segTree{
    vector<long long > tree,lazy,mn;
    void init(long long n){
        tree.resize(4*n+1,0); lazy.resize(4*n+1,0); mn.resize(4*n+1,0);
    }
    void push(long long node,long long st,long long ed){
        tree[node]+=(lazy[node]*(ed-st+1));
        mn[node]+=lazy[node];
        if(st!=ed){lazy[node*2]+=lazy[node]; lazy[node*2+1]+=lazy[node];}
        lazy[node]=0;
    }
    void update(long long node,long long st,long long ed,long long l,long long r,ll val){
        push(node,st,ed);
        if(st> r || ed<l)return;
        if(st>=l && ed<=r){
            lazy[node]+=val; push(node,st,ed);
            return;
        }
        update(node*2,st,(st+ed)/2,l,r,val);
        update(node*2+1,(st+ed)/2+1,ed,l,r,val);
        tree[node] = tree[node*2]+tree[node*2+1];
        mn[node] =min(mn[node*2],mn[node*2+1]);
    }
    pair<ll,ll> query(long long node,long long st,long long ed,long long l,long long r){ //first min, sum
        push(node,st,ed);
        if(st>r || ed<l)return {1e18,0}; //에러 나면 make_pair 함해보기 , 1e18이 충분히큰가 생각해보기
        if(st>=l && ed<=r)
            return {mn[node],tree[node]};
        auto L = query(node*2,st,(st+ed)/2,l,r);
        auto R = query(node*2+1,(st+ed)/2+1,ed,l,r);
        return make_pair(min(L.first,R.first),L.second+R.second);
    }
}seg;
void relax1(long long pos){
    //pos를 포함하는 구간을 찾아야됨
    auto it = segment.lower_bound(make_pair(pos,pos));
    if(it->first > pos) it--;
    if(it->first == pos) return;

    pair<long long,long long> p1 = make_pair(it->first,pos-1);
    pair<long long,long long> p2 = make_pair(pos,it->second);
    color[pos] = color[it->first];
    segment.erase(it);
    segment.insert(p1); segment.insert(p2);
}
void relax2(long long pos){
    auto it = segment.lower_bound(make_pair(pos,pos));
    if(it->first > pos) it--;
    if(it->second == pos) return;
    pair<long long,long long> p1 = make_pair(it->first,pos);
    pair<long long,long long> p2 = make_pair(pos+1,it->second);
    color[pos+1] = color[it->first];
    segment.erase(it);
    segment.insert(p1); segment.insert(p2);
}
int main(){
    ios::sync_with_stdio(false); cin.tie(0);
    long long n,q; cin>>n>>q;
    seg.init(n);
    int cnt = 0;
    for(long long i=1;i<=n;i++) segment.insert({i,i});
    for(long long i=1;i<=n;i++) color[i] = i;

    for(long long i=1;i<=q;i++){
        long long cmd,l,r,x; cin>>cmd>>l>>r;
        if(cmd == 1){
            cin>>x;
            relax1(l); relax2(r);
            auto it = segment.lower_bound({l,l});
            for(;;){
                cnt++;
                if(cnt>300000){

                    cout<<-1;
                    exit(0);
                    break;
                }
                auto jt = it; jt++;
                long long f = it->first;
                long long s = it->second;
                seg.update(1,1,n,it->first,it->second,abs(color[f]-x));
                segment.erase(it);
                it = jt;
                if(s == r)break;
            }
            segment.insert(make_pair(l,r));
            color[l] = x;
        }
        else{
            cout<<seg.query(1,1,n,l,r).second<<"\n";
        }
    }

    return 0;
}


#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cstring>
#include <map>
#include <queue>
#include <set>
#include <cassert>
#include <stack>
#include <bitset>
#define mkp make_pair
using namespace std;
const double EPS=1e-8;
typedef long long lon;
const lon SZ=100010,SSZ=10*SZ,INF=0x3f3f3f3f,mod=10086,S=207,T=208;
lon n,m,arr[SSZ],sum[SSZ],same[SSZ],lazy[SSZ];

void pushup(lon rt)
{
	sum[rt]=sum[rt*2]+sum[rt*2+1];
	if(same[rt*2]&&same[rt*2+1])
	{
		same[rt]=arr[rt*2]==arr[rt*2+1];
	}
	else same[rt]=0;
	if(same[rt])arr[rt]=arr[rt*2];
}

void build(lon ll,lon rr,lon rt)
{
	lon mid=(ll+rr)/2;
	if(ll==rr)
	{
		arr[rt]=ll;
		same[rt]=1;
		return;
	}
	if(ll>rr)return;
	build(ll,mid,rt*2);
	build(mid+1,rr,rt*2+1);
	pushup(rt);
}

void pushdown(int rt,int ll,int mid,int rr)
{
	if(lazy[rt])
	{
		lazy[rt*2]+=lazy[rt];
		lazy[rt*2+1]+=lazy[rt];
		sum[rt*2]+=lazy[rt]*(mid-ll+1);
		sum[rt*2+1]+=lazy[rt]*(rr-mid);
		same[rt*2]=same[rt*2+1]=1;
		arr[rt*2]=arr[rt*2+1]=arr[rt];
		lazy[rt]=0;
	}
}

void init()
{
	cin>>n>>m;
	build(1,n,1);
}

void update(lon ll,lon rr,lon rt,lon ql,lon qr,lon del)
{
	lon mid=(ll+rr)/2;
	pushdown(rt,ll,mid,rr);
	if(same[rt]&&ql<=ll&&rr<=qr)
	{

		sum[rt]+=abs(del-arr[rt])*(rr-ll+1);
		lazy[rt]=abs(del-arr[rt]);
		arr[rt]=del;
		same[rt]=1;
		//cout<<"ll: "<<ll<<" "<<rr<<" "<<lazy[rt]<<endl;
		return;
	}
	if(ll>rr)return;
	if(ql<=mid)update(ll,mid,rt*2,ql,qr,del);
	if(qr>mid)update(mid+1,rr,rt*2+1,ql,qr,del);
	pushup(rt);
	//if(ll==4&&rr==5)cout<<"45 "<<sum[rt]<<endl;
	//if(ll==6&&rr==6)cout<<"66 "<<sum[rt]<<endl;
}

lon qry(lon ll,lon rr,lon rt,lon ql,lon qr)
{
//	if(ll==6&&rr==8)
//	{
//		cout<<"ly "<<lazy[rt]<<endl;
//	}
	lon mid=(ll+rr)/2;
	pushdown(rt,ll,mid,rr);
	if(ql<=ll&&rr<=qr)
	{
		return sum[rt];
	}
	lon res=0;
	if(ql<=mid)res+=qry(ll,mid,rt*2,ql,qr);
	if(qr>mid)res+=qry(mid+1,rr,rt*2+1,ql,qr);
	return res;
}

void work()
{
	for(lon i=0;i<m;++i)
	{
		lon type,a,b,c;
		cin>>type;
		if(type==1)
		{
			cin>>a>>b>>c;
			update(1,n,1,a,b,c);
		}
		else
		{
			cin>>a>>b;
			cout<<qry(1,n,1,a,b)<<endl;
		}
	}
}

int main()
{
	//std::ios::sync_with_stdio(0);
	//freopen("d:\\1.txt","r",stdin);
	lon casenum;
	//cin>>casenum;
	//cout<<casenum<<endl;
	//for(lon time=1;time<=casenum;++time)
	//for(lon time=1;cin>>n>>len>>wid;++time)
	{
		init();
		work();
	}
	return 0;
}


#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cstring>
#include <map>
#include <queue>
#include <set>
#include <cassert>
#include <stack>
#include <bitset>
#define mkp make_pair
using namespace std;
const double EPS=1e-8;
typedef long long lon;
const lon SZ=100010,SSZ=5*SZ,INF=0x3f3f3f3f,mod=10086,S=207,T=208;
lon n,m,arr[SSZ],sum[SSZ],same[SSZ];

void pushup(lon rt)
{
	sum[rt]=sum[rt*2]+sum[rt*2+1];
	if(same[rt*2]&&same[rt*2+1])
	{
		same[rt]=arr[rt*2]==arr[rt*2+1];
	}
	else same[rt]=0;
	if(same[rt])arr[rt]=arr[rt*2];
}

void build(lon ll,lon rr,lon rt)
{
	lon mid=(ll+rr)/2;
	if(ll==rr)
	{
		arr[rt]=ll;
		same[rt]=1;
		return;
	}
	if(ll>rr)return;
	build(ll,mid,rt*2);
	build(mid+1,rr,rt*2+1);
	pushup(rt);
}

void init()
{
	cin>>n>>m;
	build(1,n,1);
}

void update(lon ll,lon rr,lon rt,lon ql,lon qr,lon del)
{
	lon mid=(ll+rr)/2;
	if(same[rt]&&ql<=ll&&rr<=qr)
	{
		sum[rt]+=abs(del-arr[rt])*(rr-ll+1);
		arr[rt]=del;
		return;
	}
	if(ql<=mid)update(ll,mid,rt*2,ql,qr,del);
	if(qr>mid)update(mid+1,rr,rt*2+1,ql,qr,del);
	pushup(rt);
}

lon qry(lon ll,lon rr,lon rt,lon ql,lon qr)
{
	lon mid=(ll+rr)/2;
	if(ql<=ll&&rr<=qr)
	{
		return sum[rt];
	}
	lon res=0;
	if(ql<=mid)res+=qry(ll,mid,rt*2,ql,qr);
	if(qr>mid)res+=qry(mid+1,rr,rt*2+1,ql,qr);
	return res;
}

void work()
{
	for(lon i=0;i<m;++i)
	{
		lon type,a,b,c;
		cin>>type;
		if(type==1)
		{
			cin>>a>>b>>c;
			update(1,n,1,a,b,c);
		}
		else
		{
			cin>>a>>b;
			cout<<qry(1,n,1,a,b)<<endl;
		}
	}
}

int main()
{
	//std::ios::sync_with_stdio(0);
	//freopen("d:\\1.txt","r",stdin);
	lon casenum;
	//cin>>casenum;
	//cout<<casenum<<endl;
	//for(lon time=1;time<=casenum;++time)
	//for(lon time=1;cin>>n>>len>>wid;++time)
	{
		init();
		work();
	}
	return 0;
}


#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cstring>
#include <map>
#include <queue>
#include <set>
#include <cassert>
#include <stack>
#include <bitset>
#define mkp make_pair
using namespace std;
const double EPS=1e-8;
typedef long long lon;
const lon SZ=100010,SSZ=5*SZ,INF=0x3f3f3f3f,mod=10086,S=207,T=208;
lon n,m,arr[SSZ],sum[SSZ],same[SSZ],lazy[SSZ];

void pushup(lon rt)
{
	sum[rt]=sum[rt*2]+sum[rt*2+1];
	if(same[rt*2]&&same[rt*2+1])
	{
		same[rt]=arr[rt*2]==arr[rt*2+1];
	}
	else same[rt]=0;
	if(same[rt])arr[rt]=arr[rt*2];
}

void build(lon ll,lon rr,lon rt)
{
	lon mid=(ll+rr)/2;
	if(ll==rr)
	{
		arr[rt]=ll;
		same[rt]=1;
		return;
	}
	if(ll>rr)return;
	build(ll,mid,rt*2);
	build(mid+1,rr,rt*2+1);
	pushup(rt);
}

void pushdown(int rt,int ll,int mid,int rr)
{
	if(lazy[rt])
	{
		lazy[rt*2]+=lazy[rt];
		lazy[rt*2+1]+=lazy[rt];
		sum[rt*2]+=lazy[rt]*(mid-ll+1);
		sum[rt*2+1]+=lazy[rt]*(rr-mid);
		same[rt*2]=same[rt*2+1]=1;
		arr[rt*2]=arr[rt*2+1]=arr[rt];
		lazy[rt]=0;
	}
}

void init()
{
	cin>>n>>m;
	build(1,n,1);
}

void update(lon ll,lon rr,lon rt,lon ql,lon qr,lon del)
{
	lon mid=(ll+rr)/2;
	pushdown(rt,ll,mid,rr);
	if(same[rt]&&ql<=ll&&rr<=qr)
	{

		sum[rt]+=abs(del-arr[rt])*(rr-ll+1);
		lazy[rt]=abs(del-arr[rt]);
		arr[rt]=del;
		same[rt]=1;
		//cout<<"ll: "<<ll<<" "<<rr<<" "<<lazy[rt]<<endl;
		return;
	}
	if(ll>rr)return;
	if(ql<=mid)update(ll,mid,rt*2,ql,qr,del);
	if(qr>mid)update(mid+1,rr,rt*2+1,ql,qr,del);
	pushup(rt);
	//if(ll==4&&rr==5)cout<<"45 "<<sum[rt]<<endl;
	//if(ll==6&&rr==6)cout<<"66 "<<sum[rt]<<endl;
}

lon qry(lon ll,lon rr,lon rt,lon ql,lon qr)
{
//	if(ll==6&&rr==8)
//	{
//		cout<<"ly "<<lazy[rt]<<endl;
//	}
	lon mid=(ll+rr)/2;
	pushdown(rt,ll,mid,rr);
	if(ql<=ll&&rr<=qr)
	{
		return sum[rt];
	}
	lon res=0;
	if(ql<=mid)res+=qry(ll,mid,rt*2,ql,qr);
	if(qr>mid)res+=qry(mid+1,rr,rt*2+1,ql,qr);
	return res;
}

void work()
{
	for(lon i=0;i<m;++i)
	{
		lon type,a,b,c;
		cin>>type;
		if(type==1)
		{
			cin>>a>>b>>c;
			update(1,n,1,a,b,c);
		}
		else
		{
			cin>>a>>b;
			cout<<qry(1,n,1,a,b)<<endl;
		}
	}
}

int main()
{
	//std::ios::sync_with_stdio(0);
	//freopen("d:\\1.txt","r",stdin);
	lon casenum;
	//cin>>casenum;
	//cout<<casenum<<endl;
	//for(lon time=1;time<=casenum;++time)
	//for(lon time=1;cin>>n>>len>>wid;++time)
	{
		init();
		work();
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define pi acos(-1)
#define ll long long
#define F(n) FI(i,n)
#define FI(i,n) FL(i,0,n)
#define FL(i,l,n) for(int i=l;i<n;++i)
#define MAXN 100005
int sum[MAXN<<2] = {};
int val[MAXN<<2] = {};
int tag[MAXN<<2] = {};
void init(int idx,int l,int r){
	if(l < r){
		int m = (l+r)>>1;
		init(idx<<1,l,m);
		init(idx<<1|1,m+1,r);
	}else{
		val[idx] = l;
	}
}
void pd(int idx,int l,int r){
	int m = (l+r) >> 1;
	if(val[idx]){
		val[idx<<1] = val[idx<<1|1] = val[idx];
	}
	if(tag[idx]){
		tag[idx<<1] += tag[idx];
		sum[idx<<1] += (m-l+1) * tag[idx];
		tag[idx<<1|1] += tag[idx];
		sum[idx<<1|1] += (r-m) * tag[idx];
		tag[idx] = 0;
	}
}
void pu(int idx,int l,int r){
	if(val[idx<<1] == val[idx<<1|1]){
		val[idx] = val[idx<<1];
	}else{
		val[idx] = 0;
	}
	sum[idx] = sum[idx<<1] + sum[idx<<1|1];
}
void upd(int idx,int l,int r,int ql,int qr,int x){
	if( l > qr || r < ql) return;
	if (ql <= l && r <= qr && val[idx]) {
		int add = abs(x-val[idx]);
		val[idx] = x;
		sum[idx] += (r-l+1) * add;
		tag[idx] += add;
		return;
	}
	pd(idx,l,r);
	int m = (l+r) >> 1;
	upd(idx<<1,l,m,ql,qr,x);
	upd(idx<<1|1,m+1,r,ql,qr,x);
	pu(idx,l,r);
}
ll query(int idx,int l,int r,int ql,int qr){
	if(l > qr || r < ql) return 0;
	if(ql <= l && r <= qr){
		return sum[idx];
	}
	pd(idx,l,r);
	int m = (l+r) >> 1;
	ll res = query(idx<<1,l,m,ql,qr);
	res += query(idx<<1|1,m+1,r,ql,qr);
	return res;
}
int main() {
	int n,m; cin>>n>>m;
	init(1,1,n);
	F(m){
		int op; scanf("%d",&op);
		if(op == 1){
			int l,r,x; scanf("%d%d%d",&l,&r,&x);
			upd(1,1,n,l,r,x);
		}else{
			int l,r; scanf("%d%d",&l,&r);
			ll ans = query(1,1,n,l,r);
			cout << ans << "\n";
		}
	}
}


#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define pi acos(-1)
#define ll long long
#define F(n) FI(i,n)
#define FI(i,n) FL(i,0,n)
#define FL(i,l,n) for(int i=l;i<n;++i)
#define MAXN 100005
#define int long long
ll sum[MAXN<<2] = {};
ll val[MAXN<<2] = {};
ll tag[MAXN<<2] = {};
void init(int idx,int l,int r){
	if(l < r){
		int m = (l+r)>>1;
		init(idx<<1,l,m);
		init(idx<<1|1,m+1,r);
	}else{
		val[idx] = l;
	}
}
void pd(int idx,int l,int r){
	int m = (l+r) >> 1;
	if(val[idx]){
		val[idx<<1] = val[idx<<1|1] = val[idx];
	}
	if(tag[idx]){
		tag[idx<<1] += tag[idx];
		sum[idx<<1] += (m-l+1) * tag[idx];
		tag[idx<<1|1] += tag[idx];
		sum[idx<<1|1] += (r-m) * tag[idx];
		tag[idx] = 0;
	}
}
void pu(int idx,int l,int r){
	if(val[idx<<1] == val[idx<<1|1]){
		val[idx] = val[idx<<1];
	}else{
		val[idx] = 0;
	}
	sum[idx] = sum[idx<<1] + sum[idx<<1|1];
}
void upd(int idx,int l,int r,int ql,int qr,int x){
	if( l > qr || r < ql) return;
	if (ql <= l && r <= qr && val[idx]) {
		int add = abs(x-val[idx]);
		val[idx] = x;
		sum[idx] += (r-l+1) * add;
		tag[idx] += add;
		return;
	}
	pd(idx,l,r);
	int m = (l+r) >> 1;
	upd(idx<<1,l,m,ql,qr,x);
	upd(idx<<1|1,m+1,r,ql,qr,x);
	pu(idx,l,r);
}
ll query(int idx,int l,int r,int ql,int qr){
	if(l > qr || r < ql) return 0;
	if(ql <= l && r <= qr){
		return sum[idx];
	}
	pd(idx,l,r);
	int m = (l+r) >> 1;
	ll res = query(idx<<1,l,m,ql,qr);
	res += query(idx<<1|1,m+1,r,ql,qr);
	return res;
}
signed main() {
	int n,m; cin>>n>>m;
	init(1,1,n);
	F(m){
		int op; scanf("%lld",&op);
		if(op == 1){
			int l,r,x; scanf("%lld%lld%lld",&l,&r,&x);
			upd(1,1,n,l,r,x);
		}else{
			int l,r; scanf("%lld%lld",&l,&r);
			ll ans = query(1,1,n,l,r);
			cout << ans << "\n";
		}
	}
}


#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define pi acos(-1)
#define ll long long
#define F(n) FI(i,n)
#define FI(i,n) FL(i,0,n)
#define FL(i,l,n) for(int i=l;i<n;++i)
#define MAXN 100005
ll sum[MAXN<<2] = {};
ll val[MAXN<<2] = {};
ll tag[MAXN<<2] = {};
void init(int idx,int l,int r){
	if(l < r){
		int m = (l+r)>>1;
		init(idx<<1,l,m);
		init(idx<<1|1,m+1,r);
	}else{
		val[idx] = l;
	}
}
void pd(int idx,int l,int r){
	int m = (l+r) >> 1;
	if(val[idx]){
		val[idx<<1] = val[idx<<1|1] = val[idx];
	}
	if(tag[idx]){
		tag[idx<<1] += tag[idx];
		sum[idx<<1] += (m-l+1) * tag[idx];
		tag[idx<<1|1] += tag[idx];
		sum[idx<<1|1] += (r-m) * tag[idx];
		tag[idx] = 0;
	}
}
void pu(int idx,int l,int r){
	if(val[idx<<1] == val[idx<<1|1]){
		val[idx] = val[idx<<1];
	}else{
		val[idx] = 0;
	}
	sum[idx] = sum[idx<<1] + sum[idx<<1|1];
}
void upd(int idx,int l,int r,int ql,int qr,int x){
	if( l > qr || r < ql) return;
	if (ql <= l && r <= qr && val[idx]) {
		int add = abs(x-val[idx]);
		val[idx] = x;
		sum[idx] += (r-l+1) * add;
		tag[idx] += add;
		return;
	}
	pd(idx,l,r);
	int m = (l+r) >> 1;
	upd(idx<<1,l,m,ql,qr,x);
	upd(idx<<1|1,m+1,r,ql,qr,x);
	pu(idx,l,r);
}
ll query(int idx,int l,int r,int ql,int qr){
	if(l > qr || r < ql) return 0;
	if(ql <= l && r <= qr){
		return sum[idx];
	}
	pd(idx,l,r);
	int m = (l+r) >> 1;
	ll res = query(idx<<1,l,m,ql,qr);
	res += query(idx<<1|1,m+1,r,ql,qr);
	return res;
}
int main() {
	int n,m; cin>>n>>m;
	init(1,1,n);
	F(m){
		int op; scanf("%d",&op);
		if(op == 1){
			int l,r,x; scanf("%d%d%d",&l,&r,&x);
			upd(1,1,n,l,r,x);
		}else{
			int l,r; scanf("%d%d",&l,&r);
			ll ans = query(1,1,n,l,r);
			cout << ans << "\n";
		}
	}
}


#include <bits/stdc++.h>

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4")

#define ll long long
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define o cout<<"BUG"<<endl;
#define	IOS ios_base::sync_with_stdio(0);
using namespace std;
const ll maxn=1e5+12+300,inf=1e9,LOG=18,mod=1e9+7,block=316;
ll n,q,a[maxn],b[maxn],add[maxn/block],sum[maxn/block],all[maxn],upd[maxn/block];
ll v[maxn/block][block],pre[maxn/block][block];
void calc1(int i){
	if(all[i]==0)
		return;
	for(int j=0;j<block;j++){
		if(upd[i]!=0)
			b[i*block+j]+=abs(upd[i]-a[i*block+j]);
		a[i*block+j]=all[i];
	}
	all[i]=0;
	upd[i]=0;
}
void calc2(int i){
	for(int j=0;j<block;j++)
		v[i][j]=a[i*block+j];
	sort(v[i],v[i]+block);
	pre[i][0]=v[i][0];
	for(int j=1;j<block;j++)
	    pre[i][j]=pre[i][j-1]+v[i][j];
}

void up(int l, int r,ll x){
	int bl=l/block;
    int br=r/block;
    if(bl==br){
		calc1(bl);
  		for(int i=l;i<=r;i++){
    		b[i]+=abs(a[i]-x);
    		sum[bl]+=abs(a[i]-x);
    		a[i]=x;
    	}
    	calc2(bl);
    }else{
    	calc1(bl);
    	calc1(br);
    	for(int i=l;i<(bl+1)*block;i++){
    		b[i]+=abs(a[i]-x);
    		sum[bl]+=abs(a[i]-x);
    		a[i]=x;
    	}
        for(int i=br*block;i<=r;i++){
    		b[i]+=abs(a[i]-x);
    		sum[br]+=abs(a[i]-x);
    		a[i]=x;
    	}
        calc2(bl);
    	calc2(br);
    	for(int i=bl+1;i<br;i++){

    		if(all[i]!=0){
    			add[i]+=abs(all[i]-x);
    			sum[i]+=abs(all[i]-x)*block;
    			all[i]=x;
    			continue;
    		}

    		int l=0,r=block-1;
    		while(l<=r){
    			int m=(l+r)/2;
    			if( v[i][m] <= x )
    				l=m+1;
    			else
    				r=m-1;
    		}

    		if(l==0){
    		    sum[i]+=pre[i][block-1]-x*block;
    		}else{
    			sum[i]+=x*l-pre[i][l-1];
    			sum[i]+=(pre[i][block-1]-pre[i][l-1])-x*(block-l);
    		}
    		upd[i]=x;
    		all[i]=x;

        }
    }

}
ll get(int l,int r){
	int bl=l/block;
    int br=r/block;
    ll res=0;
    if(bl==br){
		calc1(bl);
  		for(int i=l;i<=r;i++)
    		res+=b[i]+add[bl];
    }else{
    	calc1(bl);
    	calc1(br);
    	for(int i=l;i<(bl+1)*block;i++)
    		res+=b[i]+add[bl];
    	for(int i=br*block;i<=r;i++)
    		res+=b[i]+add[br];
    	for(int i=bl+1;i<br;i++)
    		res+=sum[i];
    }
	return res;
}
int main(){
	#ifdef LOCAL
		freopen ("test.in", "r", stdin);
 	#endif
 	scanf("%d%d",&n,&q);
    for(int i=1;i<=n;i++){
 		a[i]=i;
  		calc2(i/block);
 	}
 	while(q--){
 		int type,l,r,x;
 		scanf("%d",&type);
        if(type==1){
 			scanf("%d%d%d",&l,&r,&x);
            up(l,r,x);
 		}else{
 			scanf("%d%d",&l,&r);
 			printf("%lld\n",get(l,r));
  		}
 	}
}


#include <bits/stdc++.h>
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4")
*/
#define ll long long
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define o cout<<"BUG"<<endl;
#define	IOS ios_base::sync_with_stdio(0);
using namespace std;
const ll maxn=2e5+12,inf=1e9,LOG=18,mod=1e9+7,block=300;
ll n,q,a[maxn],b[maxn],add[maxn/block],sum[maxn/block],all[maxn];
ll v[maxn/block][block],pre[maxn/block][block];
void calc1(int i){
	if(all[i]==0)
		return;
	for(int j=0;j<block;j++)
	   	 a[i*block+j]=all[i];
	all[i]=0;
}
void calc2(int i){
	for(int j=0;j<block;j++)
		v[i][j]=a[i*block+j];
	sort(v[i],v[i]+block);
	pre[i][0]=v[i][0];
	for(int j=1;j<block;j++)
	    pre[i][j]=pre[i][j-1]+v[i][j];
}

void up(int l, int r,ll x){
	int bl=l/block;
    int br=r/block;
    if(bl==br){
		calc1(bl);
  		for(int i=l;i<=r;i++){
    		b[i]+=abs(a[i]-x);
    		sum[i/block]+=abs(a[i]-x);
    		a[i]=x;
    	}
    	calc2(bl);
    }else{
    	calc1(bl);
    	calc1(br);
    	for(int i=l;i<(bl+1)*block;i++){
    		b[i]+=abs(a[i]-x);
    		sum[i/block]+=abs(a[i]-x);
    		a[i]=x;
    	}
        for(int i=br*block;i<=r;i++){
    		b[i]+=abs(a[i]-x);
    		sum[i/block]+=abs(a[i]-x);
    		a[i]=x;
    	}
        calc2(bl);
    	calc2(br);
    	for(int i=bl+1;i<br;i++){

    		if(all[i]!=0){
    			add[i]+=abs(all[i]-x);
    			sum[i]+=abs(all[i]-x)*block;
    			all[i]=x;
    			continue;
    		}

    		int l=0,r=block-1;
    		while(l<=r){
    			int m=(l+r)/2;
    			if( v[i][m] <= x )
    				l=m+1;
    			else
    				r=m-1;
    		}
    		//for(int j=0;j<block;j++)
    		//	cout<<v[i][j]<<" ";
    		//cout<<x<<" "<<l<<endl;
    		//	sum[i]+=abs(x-v[i][j]);
    		if(l==0){
    		    sum[i]+=pre[i][block-1]-x*block;
    		}else{
    			sum[i]+=x*l-pre[i][l-1];
    			sum[i]+=(pre[i][block-1]-pre[i][l-1])-x*(block-l);
    		}
    		all[i]=x;

        }
    }

}
ll get(int l,int r){
	int bl=l/block;
    int br=r/block;
    ll res=0;
    if(bl==br){
		calc1(bl);
  		for(int i=l;i<=r;i++)
    		res+=b[i]+add[i/block];
    	calc2(bl);
    }else{
    	calc1(bl);
    	calc1(br);
    	for(int i=l;i<(bl+1)*block;i++)
    		res+=b[i]+add[i/block];
    	for(int i=br*block;i<=r;i++)
    		res+=b[i]+add[i/block];
    	calc2(bl);
    	calc2(br);
    	for(int i=bl+1;i<br;i++)
    		res+=sum[i];
    }
	return res;
}
int main(){
	#ifdef LOCAL
		freopen ("test.in", "r", stdin);
 	#endif
 	scanf("%d%d",&n,&q);
    for(int i=1;i<=n;i++){
 		a[i]=i;
  		calc2(i/block);
 	}
 	while(q--){
 		int type,l,r,x;
 		scanf("%d",&type);
        if(type==1){
 			scanf("%d%d%d",&l,&r,&x);
            up(l,r,x);
 		}else{
 			scanf("%d%d",&l,&r);
 			printf("%lld\n",get(l,r));
  		}
 	}
}


#include <bits/stdc++.h>
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4")
*/
#define ll long long
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define o cout<<"BUG"<<endl;
#define	IOS ios_base::sync_with_stdio(0);
using namespace std;
const ll maxn=1e5+12+300,inf=1e9,LOG=18,mod=1e9+7,block=500;
ll n,q,a[maxn],b[maxn],add[maxn/block],sum[maxn/block],all[maxn];
ll v[maxn/block][block],pre[maxn/block][block];
void calc1(int i){
	if(all[i]==0)
		return;
	for(int j=0;j<block;j++)
	   	 a[i*block+j]=all[i];
	all[i]=0;
}
void calc2(int i){
	for(int j=0;j<block;j++)
		v[i][j]=a[i*block+j];
	sort(v[i],v[i]+block);
	pre[i][0]=v[i][0];
	for(int j=1;j<block;j++)
	    pre[i][j]=pre[i][j-1]+v[i][j];
}

void up(int l, int r,ll x){
	int bl=l/block;
    int br=r/block;
    if(bl==br){
		calc1(bl);
  		for(int i=l;i<=r;i++){
    		b[i]+=abs(a[i]-x);
    		sum[i/block]+=abs(a[i]-x);
    		a[i]=x;
    	}
    	calc2(bl);
    }else{
    	calc1(bl);
    	calc1(br);
    	for(int i=l;i<(bl+1)*block;i++){
    		b[i]+=abs(a[i]-x);
    		sum[i/block]+=abs(a[i]-x);
    		a[i]=x;
    	}
        for(int i=br*block;i<=r;i++){
    		b[i]+=abs(a[i]-x);
    		sum[i/block]+=abs(a[i]-x);
    		a[i]=x;
    	}
        calc2(bl);
    	calc2(br);
    	for(int i=bl+1;i<br;i++){

    		if(all[i]!=0){
    			add[i]+=abs(all[i]-x);
    			sum[i]+=abs(all[i]-x)*block;
    			all[i]=x;
    			continue;
    		}

    		int l=0,r=block-1;
    		while(l<=r){
    			int m=(l+r)/2;
    			if( v[i][m] <= x )
    				l=m+1;
    			else
    				r=m-1;
    		}
    		//for(int j=0;j<block;j++)
    		//	cout<<v[i][j]<<" ";
    		//cout<<x<<" "<<l<<endl;
    		//	sum[i]+=abs(x-v[i][j]);
    		if(l==0){
    		    sum[i]+=pre[i][block-1]-x*block;
    		}else{
    			sum[i]+=x*l-pre[i][l-1];
    			sum[i]+=(pre[i][block-1]-pre[i][l-1])-x*(block-l);
    		}
    		all[i]=x;

        }
    }

}
ll get(int l,int r){
	int bl=l/block;
    int br=r/block;
    ll res=0;
    if(bl==br){
		calc1(bl);
  		for(int i=l;i<=r;i++)
    		res+=b[i]+add[i/block];
    	calc2(bl);
    }else{
    	calc1(bl);
    	calc1(br);
    	for(int i=l;i<(bl+1)*block;i++)
    		res+=b[i]+add[i/block];
    	for(int i=br*block;i<=r;i++)
    		res+=b[i]+add[i/block];
    	calc2(bl);
    	calc2(br);
    	for(int i=bl+1;i<br;i++)
    		res+=sum[i];
    }
	return res;
}
int main(){
	#ifdef LOCAL
		freopen ("test.in", "r", stdin);
 	#endif
 	scanf("%d%d",&n,&q);
    for(int i=1;i<=n;i++){
 		a[i]=i;
  		calc2(i/block);
 	}
 	while(q--){
 		int type,l,r,x;
 		scanf("%d",&type);
        if(type==1){
 			scanf("%d%d%d",&l,&r,&x);
            up(l,r,x);
 		}else{
 			scanf("%d%d",&l,&r);
 			printf("%lld\n",get(l,r));
  		}
 	}
}


#include <bits/stdc++.h>
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4")
*/
#define ll long long
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define o cout<<"BUG"<<endl;
#define	IOS ios_base::sync_with_stdio(0);
using namespace std;
const ll maxn=1e5+12+300,inf=1e9,LOG=18,mod=1e9+7,block=300;
ll n,q,a[maxn],b[maxn],add[maxn/block],sum[maxn/block],all[maxn];
ll v[maxn/block][block],pre[maxn/block][block];
void calc1(int i){
	if(all[i]==0)
		return;
	for(int j=0;j<block;j++)
	   	 a[i*block+j]=all[i];
	all[i]=0;
}
void calc2(int i){
	for(int j=0;j<block;j++)
		v[i][j]=a[i*block+j];
	sort(v[i],v[i]+block);
	pre[i][0]=v[i][0];
	for(int j=1;j<block;j++)
	    pre[i][j]=pre[i][j-1]+v[i][j];
}

void up(int l, int r,ll x){
	int bl=l/block;
    int br=r/block;
    if(bl==br){
		calc1(bl);
  		for(int i=l;i<=r;i++){
    		b[i]+=abs(a[i]-x);
    		sum[i/block]+=abs(a[i]-x);
    		a[i]=x;
    	}
    	calc2(bl);
    }else{
    	calc1(bl);
    	calc1(br);
    	for(int i=l;i<(bl+1)*block;i++){
    		b[i]+=abs(a[i]-x);
    		sum[i/block]+=abs(a[i]-x);
    		a[i]=x;
    	}
        for(int i=br*block;i<=r;i++){
    		b[i]+=abs(a[i]-x);
    		sum[i/block]+=abs(a[i]-x);
    		a[i]=x;
    	}
        calc2(bl);
    	calc2(br);
    	for(int i=bl+1;i<br;i++){

    		if(all[i]!=0){
    			add[i]+=abs(all[i]-x);
    			sum[i]+=abs(all[i]-x)*block;
    			all[i]=x;
    			continue;
    		}

    		int l=0,r=block-1;
    		while(l<=r){
    			int m=(l+r)/2;
    			if( v[i][m] <= x )
    				l=m+1;
    			else
    				r=m-1;
    		}
    		//for(int j=0;j<block;j++)
    		//	cout<<v[i][j]<<" ";
    		//cout<<x<<" "<<l<<endl;
    		//	sum[i]+=abs(x-v[i][j]);
    		if(l==0){
    		    sum[i]+=pre[i][block-1]-x*block;
    		}else{
    			sum[i]+=x*l-pre[i][l-1];
    			sum[i]+=(pre[i][block-1]-pre[i][l-1])-x*(block-l);
    		}
    		all[i]=x;

        }
    }

}
ll get(int l,int r){
	int bl=l/block;
    int br=r/block;
    ll res=0;
    if(bl==br){
		calc1(bl);
  		for(int i=l;i<=r;i++)
    		res+=b[i]+add[i/block];
    	calc2(bl);
    }else{
    	calc1(bl);
    	calc1(br);
    	for(int i=l;i<(bl+1)*block;i++)
    		res+=b[i]+add[i/block];
    	for(int i=br*block;i<=r;i++)
    		res+=b[i]+add[i/block];
    	calc2(bl);
    	calc2(br);
    	for(int i=bl+1;i<br;i++)
    		res+=sum[i];
    }
	return res;
}
int main(){
	#ifdef LOCAL
		freopen ("test.in", "r", stdin);
 	#endif
 	scanf("%d%d",&n,&q);
    for(int i=1;i<=n;i++){
 		a[i]=i;
  		calc2(i/block);
 	}
 	while(q--){
 		int type,l,r,x;
 		scanf("%d",&type);
        if(type==1){
 			scanf("%d%d%d",&l,&r,&x);
            up(l,r,x);
 		}else{
 			scanf("%d%d",&l,&r);
 			printf("%lld\n",get(l,r));
  		}
 	}
}