#include <stdio.h>                                                                                                                                                                                                                
#include <stdlib.h>                                                                                                                                                                                                               
#include <string.h>                                                                                                                                                                                                               
                                                                                                                                                                                                                                  
int main(void)                                                                                                                                                                                                                    
{                                                                                                                                                                                                                                 
        int a, b, c, d, i, list[101] = { 0 }, ans = 0;                                                                                                                                                                            
                                                                                                                                                                                                                                  
        scanf("%d %d %d %d", &a, &b, &c, &d);                                                                                                                                                                                     
                                                                                                                                                                                                                                  
        for (i = a; i < b; i++) {                                                                                                                                                                                                 
                list[i]++;                                                                                                                                                                                                        
        }                                                                                                                                                                                                                                                                                                                
        for (i = c; i < d; i++) {                                                                                                                                                                                                 
                list[i]++;                                                                                                                                                                                                        
        }                                                                                                                                                                                                                         
                                                                                                                                                                                                                                  
        for (i = 0; i < 101; i++) {                                                                                                                                                                                               
                if (list[i] == 2) {                                                                                                                                                                                               
                        ans++;                                                                                                                                                                                                    
                }                                                                                                                                                                                                                 
        }                                                                                                                                                                                                                         
        printf("%d\n", ans);                                                                                                                                                                                                      
        return 0;                                                                                                                                                                                                                 
}

Measured memory_bytes: 128