#include <bits/stdc++.h>
int r, h, m, k = 0, j;
int main() {
  scanf("%d:%d", &h, &m);
  while (m != (h % 10) * 10 + h / 10) {
    k++;
    m++;
    if (m > 59) {
      h++;
      m = 0;
      if (h > 23) h = 0;
    }
  }
  printf("%d", k);
  return 0;
}
