#55299: ans


yp11451032@yphs.tp.edu.tw (711-23吳嘉恩)


#include<bits/stdc++.h>
using namespace std;
int main(){
    int m1,d1,m2,d2,now,bir,ans;
    int d[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
    cin>>m1>>d1;
    cin>>m2>>d2;
    now=d1;
    for(int i=1;i<m1;i++){
        now+=d[i];
    }
    bir=d2;
    for(int i=1;i<m2;i++){
        bir+=d[i];
    }
    ans=(bir-now+365)%365;
    cout<<ans<<'\n';
}