#include <bits/stdc++.h>
using namespace std;
bool ispalin(string s) {
  bool t = true;
  for (int i = 0; i < s.size() / 2; i++) {
    if (s[i] != s[s.size() - i - 1]) t = false;
  }
  return t;
}
int main() {
  int ans = 0, h, m;
  scanf("%d:%d", &h, &m);
  for (;; ans++) {
    if (h % 10 == m / 10 && h / 10 == m % 10) break;
    m++;
    if (m == 60) {
      h++;
      m = 0;
    }
    if (h == 24) h = 0;
  }
  cout << ans;
  return 0;
}
