#include <bits/stdc++.h>
using namespace std;
template <typename T, typename U>
static void amax(T &x, U y) {
  if (x < y) x = y;
}
template <typename T, typename U>
static void amin(T &x, U y) {
  if (x > y) x = y;
}
int main() {
  int d, h, p, ans, x, a;
  scanf("%d:%d", &h, &p);
  d = h % 10;
  x = d * 10 + h / 10;
  a = (d + 1) * 10 + h / 10;
  if (a == 42) a = 0;
  if (d == 6 || d == 7 || d == 8 || d == 9)
    ans = (9 - d) * 60 + (59 - p), ans += (h > 10) ? 3 : 2;
  else {
    if (p <= x)
      ans = x - p;
    else {
      if ((d + 1) == 6)
        ans = (59 - p) + 4 * 60, ans += (h > 10) ? 3 : 2;
      else
        ans = (59 - p) + 1 + a;
    }
  }
  printf("%d\n", ans);
  return 0;
}
