#include <bits/stdc++.h>
using namespace std;
void int2(int aa, int& a, int& b) {
  if (aa < 10) {
    a = 0;
    b = aa;
  } else {
    a = aa / 10;
    b = aa % 10;
  }
}
bool is_pal(int a, int b) {
  int a1, a2, b1, b2;
  int2(a, a1, a2);
  int2(b, b1, b2);
  return (a1 == b2 && a2 == b1);
}
int main() {
  string time;
  int hh, mm;
  int curH, curM;
  int mins = 0;
  cin >> time;
  hh = stoi(time.substr(0, 2));
  mm = stoi(time.substr(3, 2));
  curM = mm;
  curH = hh;
  while (true) {
    if (is_pal(curH, curM)) break;
    mins++;
    curM++;
    if (curM == 60) {
      curH++;
      curM = 0;
    }
    if (curH == 24) curH = 0;
  }
  cout << mins << endl;
  return 0;
}
