#include <iostream>
#include <string>

int func(int x)
{
  return x * x;
}

int main(void)
{
  const int max_x = 600;
  int d = 0;

  while (std::cin >> d) {
    int loop = max_x / d;

    int sum = 0;
    for (int i = 0; i < loop; i++) {
      sum += d * func(d * i);
    }

    std::cout << sum << std::endl;
  }

  return 0;
}
#include<stdio.h>

int main()
{
    int h1,h2,m1,m2,k;
    scanf("%d%d%d%d%d",&h1,&m1,&h2,&m2,&k);
    m1+=60*h1;
    m2+=60*h2;
    printf("%d\n",m2-m1-k);
    return 0;
}