#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, c, d;
  int h, s;
  scanf("%d:%d", &h, &s);
  int sums = 0;
  while (1) {
    a = h % 10, b = (h / 10) % 10, c = s % 10, d = (s / 10) % 10;
    if (a * 10 + b == d * 10 + c)
      break;
    else {
      s++, sums++;
      if (s >= 60) {
        s -= 60;
        h++;
        if (h == 24) h -= 24;
      }
    }
  }
  printf("%d\n", sums);
  return 0;
}
