// 2025/8/10: 911Lil_Marrikh - ECPC-2025 Medalists
#include <bits/stdc++.h>
using namespace std;
// #define int int64_t
#define ll int64_t
#define el "\n"
const int MAX_NODES = 1e7 + 5;
template <typename T = int>
struct DynamicSegTree {
struct Node {
int ls = 0, rs = 0;
T sum = 0, lz = 0;
} t[MAX_NODES];
int root = 0, tot = 0;
void push(int u, int l, int r) {
if (!t[u].lz || l == r) return;
if (!t[u].ls) t[u].ls = ++tot;
if (!t[u].rs) t[u].rs = ++tot;
int mid = l + (r - l) / 2, ls = t[u].ls, rs = t[u].rs;
T lz = t[u].lz;
t[ls].sum = (mid - l + 1); t[ls].lz = true;
t[rs].sum = (r - mid); t[rs].lz = true;
t[u].lz = 0;
}
void update(int& u, int l, int r, int ql, int qr) {
if (!u) u = ++tot;
if (ql <= l && r <= qr) {
t[u].sum = (r - l + 1);
t[u].lz = true;
return;
}
push(u, l, r);
int mid = l + (r - l) / 2;
if (ql <= mid) update(t[u].ls, l, mid, ql, qr);
if (qr > mid) update(t[u].rs, mid + 1, r, ql, qr);
t[u].sum = t[t[u].ls].sum + t[t[u].rs].sum;
}
T query(int u, int l, int r, int ql, int qr) {
if (!u || ql > r || qr < l) return 0;
if (ql <= l && r <= qr) return t[u].sum;
push(u, l, r);
int mid = l + (r - l) / 2;
return query(t[u].ls, l, mid, ql, qr) + query(t[u].rs, mid + 1, r, ql, qr);
}
};
DynamicSegTree sg;
void work(int tc) {
int n; cin >> n;
int c = 0;
while (n--) {
int d, x, y; cin >> d >> x >> y;
x += c, y += c;
if (d == 1) {
c = sg.query(sg.root, 1, 1e9, x, y);
cout << c << el;
} else {
sg.update(sg.root, 1, 1e9, x, y);
}
}
}
signed main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
// #ifndef ONLINE_JUDGE
freopen("f.in", "r", stdin);
freopen("f.out", "w", stdout);
// #endif
int _t = 1;
// cin >> _t;
for (int i = 1; i <= _t; i++) {
work(i);
}
}