#include <iostream>
#include <vector>
#include <sstream>
using namespace std;

int main(){
    string str;
    cin>>str;
    istringstream iss{str};
    vector<string> res;
    string s;
    while(std::getline(iss,s,',')){
        res.push_back(s);
    }
    // 字符串转数字
    long long count1 = 0;
    int count2 = 0;
    vector<long long> res_int;
    for(int i = 1; i < 4; ++i){
        istringstream iss1{res[i]};
        if(i == 1 || i == 3){
            iss1>>count1;
            res_int.push_back(count1); 
        }
    }
    cout<<res_int[1] - res_int[0] -1<<endl;
}