#include <bits/stdc++.h>
using namespace std;
int h1, h2, m1, m2;
bool pal() {
  if (h1 == m2 && h2 == m1)
    return true;
  else
    return 0;
}
int main() {
  char ch;
  cin >> ch;
  h1 = ch - '0';
  cin >> ch;
  h2 = ch - '0';
  cin >> ch;
  cin >> ch;
  m1 = ch - '0';
  cin >> ch;
  m2 = ch - '0';
  if (pal() == true) {
    cout << 0;
    return 0;
  }
  int h, m, fc = 0;
  while (pal() == false) {
    if ((h1 == 2 && h2 == 3 && m1 == 5 && m2 == 9)) {
      fc++;
      break;
    }
    h = h1 * 10 + h2;
    m = m1 * 10 + m2;
    m++;
    h += m / 60;
    m %= 60;
    h1 = h / 10;
    h2 = h % 10;
    m1 = m / 10;
    m2 = m % 10;
    fc++;
  }
  cout << fc;
  return 0;
}
