#include <cstdio> #include <bitset> using namespace std; const int N = 105; bitset<N*N*N> b[105]; int n,l[N],r[N]; int main(){ scanf("%d",&n); for(int i = 1;i <= n;i++) scanf("%d%d",l+i,r+i); b[0].set(0); for(int i = 1;i <= n;i++){ for(int j = l[i];j <= r[i];j++){ b[i]|=(b[i-1]<<(j*j)); } } printf("%d\n",b[n].count()); return 0; }