#include <cmath>
#include <cctype>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>

#include <algorithm>
#include <vector>
#include <string>
#include <sstream>
#include <iostream>
#include <functional>
#include <map>
#include <set>

using namespace std;

#define forn(i, n) for (int i = 0; i < (int)(n); i++)
#define forit(i, a) for (__typeof((a).begin()) i = (a).begin(); i != (a).end(); i++)
#define sz(a) (int)(a).size()
#define all(a) (a).begin(), (a).end()
#define zero(a) memset(a, 0, sizeof(a))
#define pb push_back
#define mp make_pair

typedef long long ll;
typedef vector <int> vi;
typedef pair <int, int> pii;

template <class T> T inline sqr(T x) { return x * x; }

#define NAME "numeric"

struct rational
{
  int a, b;

  void read()
  {
    char s[100];
    scanf(" %[-0-9/]s", s);
    if (strchr(s, '/'))
      sscanf(s, "%d%*c%d", &a, &b);
    else
      sscanf(s, "%d", &a), b = 1;
  }

  int down() { return (int)floor((double)a / b); }
  int up() { a += b - 1; return down(); }
};

int main()
{
  freopen(NAME ".in", "r", stdin);
  freopen(NAME ".out", "w", stdout);

  rational A, B;
  int L, R;
  char open, close;
  scanf("%c", &open);
  A.read();
  scanf("%*c");
  B.read();
  scanf("%c", &close);

//  printf("%c %d/%d , %d/%d %c\n", open, A.a, A.b, B.a, B.b, close);

  if (open == '(') A.a++;
  if (close == ')') B.a--;

  L = A.up();
  R = B.down();
  printf("%d\n", R - L + 1);
  return 0;
}