#include <bits/stdc++.h>
using namespace std;
int main() {
  int hh, mm;
  scanf("%d:%d", &hh, &mm);
  for (int i = 0; i < 1440; ++i) {
    if (hh == ((mm / 10) + (mm % 10) * 10)) {
      printf("%d\n", i);
      break;
    }
    ++mm;
    if (mm == 60) ++hh, mm = 0;
    if (hh == 24) hh = 0;
  }
  return 0;
}
