#include <bits/stdc++.h>
using namespace std;
int pelindrome(int n) {
  int i, a, sum = 0;
  if (n < 10) return n * 10;
  for (i = 0;; i++) {
    a = n % 10;
    n = n / 10;
    sum = sum * 10 + a;
    if (n == 0) break;
  }
  return sum;
}
int main() {
  int h, m, i, u, uu, hh, flag, a, b;
  while (scanf("%d:%d", &h, &m) == 2) {
    hh = h;
    flag = 0;
    for (i = m;; i = i + u) {
      u = 1;
      if (i == 60) {
        i = i % 60;
        h = h + 1;
        if (h >= 24) {
          flag = 1;
          h = h % 24;
        }
      }
      a = pelindrome(i);
      if (h == a) {
        uu = i;
        break;
      }
    }
    if (flag == 1) {
      b = (24 - hh) + h;
      b = b * 60;
      if (m >= uu)
        printf("%d\n", b - (m - uu));
      else
        printf("%d\n", b + (uu - m));
    } else {
      b = (h - hh) * 60;
      if (m >= uu)
        printf("%d\n", b - (m - uu));
      else
        printf("%d\n", b + (uu - m));
    }
  }
  return 0;
}
