This problem was deleted from the contest, because it was used previously at another competition.

Input

Output

Examples

Input

1 1
1 2 100


Output

6
#include <bits/stdc++.h>
using namespace std;
const int N = 100000 + 10;
const int MOD = 1000000000 + 7;
const int INF = 1000000000 + 10;
long long n, m, ret, p;
long long mu[N], notP[N];
long long calc(long long lim) {
  long long ret = 0;
  for (long long d = 1; d <= n; ++d) {
    for (long long x = d; x <= n; x += d) {
      long long l = 0, r = m + 10, mid;
      for (; l + 1 < r;) {
        mid = (l + r) / 2;
        if (d * mid > m) {
          r = mid;
          continue;
        }
        if ((mid * d) * (mid * d) + x * x < lim)
          l = mid;
        else
          r = mid;
      }
      if (l == 0) break;
      ret += 2 * mu[d] * (n + 1 - x) % p *
             ((l * (m + 1) - (l * (l + 1) / 2) % p * d) % p + p) % p;
      ret = (ret + p) % p;
    }
  }
  if (lim > 1) {
    ret = (ret + n * (m + 1) + m * (n + 1)) % p;
  }
  return ret;
}
void solve() {
  for (int i = 1; i < N; ++i) {
    mu[i] = 1;
  }
  for (long long i = 2; i < N; ++i) {
    if (notP[i]) continue;
    for (long long j = i; j < N; j += i) {
      if (j % (i * i) == 0)
        mu[j] = 0;
      else {
        mu[j] = -mu[j];
      }
      notP[j] = true;
    }
  }
  long long l, r;
  cin >> n >> m;
  if (n > m) swap(n, m);
  cin >> l >> r;
  cin >> p;
  cout << (calc(r * r + 1) - calc(l * l) + p) % p << endl;
}
int main() {
  solve();
  return 0;
}
