#include <cstdio>  
#include <iostream>  
#include <algorithm>  
#include <cstring>  
using  namespace  std; 
int  w, n, len, ans, b[ 1005 ] [ 1005 ] , pd[ 10005 ] ; 
double  f[ 1005 ] ; 
struct  rec
{ double  x1, x2, y1, y2; int  c; 
} a[ 105 ] ; 
int  main ( ) 
{ freopen ( "b.in" , "r" , stdin ) ; freopen ( "b.out" , "w" , stdout ) ; scanf ( "%d" , & n) ; for  ( int  i= 1 ; i<= n; i++ ) { scanf ( "%lf %lf %lf %lf %d" , & a[ i] . x1, & a[ i] . y1, & a[ i] . x2, & a[ i] . y2, & a[ i] . c) ; f[ ++ w] = a[ i] . x1- 0.5 ; f[ ++ w] = a[ i] . y1- 0.5 ; f[ ++ w] = a[ i] . x2+ 0.5 ; f[ ++ w] = a[ i] . y2+ 0.5 ; f[ ++ w] = ( a[ i] . x1+ = 0.5 ) ; f[ ++ w] = ( a[ i] . y1+ = 0.5 ) ; f[ ++ w] = ( a[ i] . x2- = 0.5 ) ; f[ ++ w] = ( a[ i] . y2- = 0.5 ) ; } sort ( f+ 1 , f+ 1 + w) ; len= unique ( f+ 1 , f+ 1 + w) - f- 1 ; for  ( int  i= 1 ; i<= n; i++ ) { a[ i] . x1= lower_bound ( f+ 1 , f+ 1 + len, a[ i] . x1) - f; a[ i] . y1= lower_bound ( f+ 1 , f+ 1 + len, a[ i] . y1) - f; a[ i] . x2= lower_bound ( f+ 1 , f+ 1 + len, a[ i] . x2) - f; a[ i] . y2= lower_bound ( f+ 1 , f+ 1 + len, a[ i] . y2) - f; b[ ( int ) a[ i] . x1] [ ( int ) a[ i] . y1] + = a[ i] . c; b[ ( int ) a[ i] . x2+ 1 ] [ ( int ) a[ i] . y2+ 1 ] + = a[ i] . c; b[ ( int ) a[ i] . x1] [ ( int ) a[ i] . y2+ 1 ] - = a[ i] . c; b[ ( int ) a[ i] . x2+ 1 ] [ ( int ) a[ i] . y1] - = a[ i] . c; } for  ( int  i= 1 ; i<= len; i++ ) for  ( int  j= 1 ; j<= len; j++ ) { b[ i] [ j] + = b[ i- 1 ] [ j] + b[ i] [ j- 1 ] - b[ i- 1 ] [ j- 1 ] ; if  ( ( b[ i] [ j] ) && ( ! pd[ b[ i] [ j] ] ) ) ans++ , pd[ b[ i] [ j] ] ++ ; } printf ( "%d" , ans) ; fclose ( stdin ) ; fclose ( stdout ) ; return  0 ; 
}